iOS实现旋转
2018-07-20 来源:open-open
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic)UILabel *label;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGRect labelFrame = CGRectMake(100, 100,100, 50);
self.label = [[UILabel alloc] initWithFrame:labelFrame];
self.label.font = [UIFont fontWithName:@"Helvetica" size:36];
self.label.text = @"XxxX";
self.label.textAlignment = NSTextAlignmentCenter;
self.label.backgroundColor = [UIColor brownColor];
[self.view addSubview:self.label];
[self rotateLabelDown];
}
- (void)rotateLabelDown{
[UIView animateWithDuration:10 animations:^{
self.label.layer.anchorPoint = CGPointMake(0.5, 0.5);
//self.label.transform = CGAffineTransformMakeRotation(-90); //逆时针旋转
self.label.transform = CGAffineTransformMakeRotation(M_PI);
} completion:^(BOOL finished) {
[self rotateLabelUp];
}];
}
- (void)rotateLabelUp{
[UIView animateWithDuration:10 animations:^{
self.label.layer.anchorPoint = CGPointMake(0.5, 0.5);
self.label.transform = CGAffineTransformMakeRotation(0);
} completion:^(BOOL finished) {
[self rotateLabelDown];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
标签: isp
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐