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

ui基础--放大缩小动画

时间:2016-08-02 20:37:42      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

首先我们用pod安装2个三方库:

use_frameworks!

target Love--动画 do
pod pop, ~> 1.0.9
pod POP+MCAnimate, ~> 2.0

end

实现代码:

#import "RootViewController.h"


@interface RootViewController ()
@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong) dispatch_source_t timer;

@end

@implementation RootViewController

- (void)viewWillAppear:(BOOL)animated
{
    
    [self setupScoreAnimation];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"臭美";
    
    self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 300, 100, 100)];
    
    UIImage *image = [UIImage imageNamed:@"10"];
    
    self.myImageView.layer.cornerRadius = 50;
    self.myImageView.layer.masksToBounds = YES;
    
    self.myImageView.image = image;
    
    [self.view addSubview:_myImageView];
    
}

- (void)setupScoreAnimation
{
    dispatch_queue_t queue = dispatch_get_main_queue();
    
    self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
    dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC));
    uint64_t interval = (uint64_t)(1.0 * NSEC_PER_SEC);
    dispatch_source_set_timer(self.timer, start, interval, 0);
    dispatch_source_set_event_handler(self.timer, ^{
        
        [self animationStar];
    });
    
    dispatch_resume(self.timer);
}

- (void)animationStar
{
    [NSObject pop_animate:^{
        
        self.myImageView.pop_spring.pop_scaleXY = CGPointMake(1.5, 1.5);
        self.myImageView.pop_springBounciness = 20;
        self.myImageView.pop_springSpeed = 20;
    } completion:^(BOOL finished) {
        
        self.myImageView.pop_spring.pop_scaleXY = CGPointMake(1, 1);
        self.myImageView.pop_springBounciness = 20;
        self.myImageView.pop_springSpeed = 20;
    }];
}



@end

自己可以试试哈...

记得要将timer至nil啊.

- (void)viewDidDisappear:(BOOL)animated
{
    dispatch_cancel(self.timer);
    self.timer = nil;
}

完成...

ui基础--放大缩小动画

标签:

原文地址:http://www.cnblogs.com/LzwBlog/p/5730323.html

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