• iOS开发动画(Animation)图片360度不停旋转


     1 {
     2     CGFloat angle;
     3 }
     4 
     5 - (void)viewDidLoad {
     6     [super viewDidLoad];
     7     angle = 0;
     8     [self startAnimation];
     9 }
    10 
    11 //方法1
    12 -(void) startAnimation
    13 {
    14     [UIView beginAnimations:nil context:nil];
    15     [UIView setAnimationDuration:0.01];
    16     [UIView setAnimationDelegate:self];
    17     [UIView setAnimationDidStopSelector:@selector(endAnimation)];
    18     self.scanImage.transform = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));
    19     [UIView commitAnimations];
    20 }
    21 
    22 -(void)endAnimation
    23 {
    24     angle += 2;
    25     [self startAnimation];
    26 }
    27 
    28 //方法2
    29 - (void)startAnimation
    30 {
    31     CGAffineTransform endAngle = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));
    32     
    33     [UIView animateWithDuration:0.01 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
    34         self.scanImage.transform = endAngle;
    35     } completion:^(BOOL finished) {
    36         angle += 2; [self startAnimation];
    37     }];
    38 }
  • 相关阅读:
    本周面试总结
    本周面试总结
    本周面试题总结
    网络请求AJAX
    es6数组、对象的解构赋值
    es6箭头函数
    es6总结
    js限定输入为数字包括负数正则
    js限定输入为非负数,浮点数正则
    js数值千分隔(正则)
  • 原文地址:https://www.cnblogs.com/codemakerhj/p/5462618.html
Copyright © 2020-2023  润新知