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;
    }

    完成...

  • 相关阅读:
    上经 -- 乾【卦一】乾为天(三)
    上经 -- 乾【卦一】乾为天(一)
    8. Shell 文件包含
    7. Shell 函数
    6. Shell 流程控制
    5. test命令
    4. printf 命令
    3. Shell 基本运算符
    2. Shell 传递参数
    shell介绍
  • 原文地址:https://www.cnblogs.com/LzwBlog/p/5730323.html
Copyright © 2011-2022 走看看