微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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];
}

希望这也有助于其他人!

原文地址:https://www.jb51.cc/iOS/332669.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐