码迷,mamicode.com
首页 > 其他好文 > 详细

实现UIView的无限旋转动画(非CALayer动画)

时间:2015-02-05 23:06:47      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

实现UIView的无限旋转动画(非CALayer动画)

技术分享

效果:

技术分享

素材:

技术分享

源码:

//
//  ViewController.m
//  Animation
//
//  Created by YouXianMing on 15/2/5.
//  Copyright (c) 2015年 YouXianMing. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic, strong) UIImageView  *circleView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor blackColor];
    
    self.circleView                 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    self.circleView.image           = [UIImage imageNamed:@"bg"];
    self.circleView.center          = self.view.center;
    [self.view addSubview:self.circleView];
    
    [self rotateImageView];
}

- (void)rotateImageView {
    // 一秒钟旋转几圈
    CGFloat circleByOneSecond = 1.5f;
    
    // 执行动画
    [UIView animateWithDuration:1.f / circleByOneSecond
                          delay:0
                        options:UIViewAnimationOptionCurveLinear
                     animations:^{
        self.circleView.transform = CGAffineTransformRotate(self.circleView.transform, M_PI_2);
    }
                     completion:^(BOOL finished){
        [self rotateImageView];
    }];
}

@end

核心源码(递归调用):

技术分享

 

实现UIView的无限旋转动画(非CALayer动画)

标签:

原文地址:http://www.cnblogs.com/YouXianMing/p/4276118.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!