zoukankan      html  css  js  c++  java
  • ui基础--放大缩小动画

    首先我们用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;
    }

    完成...

  • 相关阅读:
    RabbitMQ学习系列二:.net 环境下 C#代码使用 RabbitMQ 消息队列
    越狱Season 1- Episode 22: Flight
    越狱Season 1-Episode 21: Go
    越狱Season 1-Episode 20: Tonight
    越狱Season 1-Episode 19: The Key
    越狱Season 1- Episode 18: Bluff
    越狱Season 1-Episode 17: J-Cat
    越狱Season 1- Episode 16
    越狱Season 1-Episode 15: By the Skin and the Teeth
    越狱Season 1-Episode 14: The Rat
  • 原文地址:https://www.cnblogs.com/LzwBlog/p/5730323.html
Copyright © 2011-2022 走看看