ios – 如何从右上角动画/旋转UIView 90度?

我一直在寻找几个小时试图找到一种方法来动画/从右上角旋转UIView 90度.

效果应该像屏幕顶部的摆动门一样.

希望有人可以帮忙!

解决方法

所以在我按下后,我突然把两个和两个放在一起,并认为metronome样品的工作类似于一个摆动的门,这让我有了一些其他的可能性.

这是我的解决方案:

- (void)viewDidLoad {
    [super viewDidLoad];

    // Set the anchor point and center so the view swings from the upper right
    swingView.layer.anchorPoint = CGPointMake(1.0,0.0);
    swingView.center = CGPointMake(CGRectGetWidth(self.view.bounds),0.0);

    // Rotate 90 degrees to hide it off screen
    CGAffineTransform rotationTransform = CGAffineTransformIdentity;
    rotationTransform = CGAffineTransformRotate(rotationTransform,degreesToradians(90));
    swingView.transform = rotationTransform;
}

...

- (void)animateSwing {

    CGAffineTransform swingTransform = CGAffineTransformIdentity;
    swingTransform = CGAffineTransformRotate(swingTransform,degreesToradians(0));

    [UIView beginAnimations:@"swing" context:swingView];
    [UIView setAnimationDuration:0.25];

    swingView.transform = swingTransform;

    [UIView commitAnimations];
}

希望这也有助于其他人!

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...