zoukankan      html  css  js  c++  java
  • iOS开发UUIView动画方法总结

    #动画设置 UIView动画实现
    @interface ViewController ()
    @property (weak, nonatomic) IBOutlet UIView *myView;
    @property (weak, nonatomic) IBOutlet UIView *redView;
    @end
    
    #pragma mark - UIView类实现动画
    
    #pragma mark - Animating Views with Block Object
    @implementation ViewController
    - (IBAction)handleViewOne:(id)sender {
    
     /* 方法1:Block语法的动画 */
         
        [UIView animateWithDuration:3 animations:^{
            
            /* 控件的属性发生改变 */
            self.myView.frame = CGRectMake(0, 100, 375, 200);
            self.myView.backgroundColor = [UIColor greenColor];
        
        }];
    
     /* 方法2 */
    
        [UIView animateWithDuration:3 animations:^{
            /* 动画开始的代码*/
            self.myView.frame = CGRectMake(0, 200, 375, 130);
            self.myView.backgroundColor = [UIColor cyanColor];
                
        } completion:^(BOOL finished) {
            
            /* 动画执行后的代码段 */
            self.myView.frame = CGRectMake(0, 58, 375, 130);
            
        }];
        
    /* 方法3 */
            /* options参数:动画相关参数,多个之间用 | 分开*/
        [UIView animateWithDuration:3 delay:1 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{
            
            /* 开始动画的View属性值 */
            self.myView.frame = CGRectMake(0, 200, 375, 130);
            self.myView.backgroundColor = [UIColor redColor];
                    
        } completion:^(BOOL finished) {
        }];
    
     /* 方法4 过渡动画效果 */
        
        [UIView transitionWithView:self.myView duration:3 options:UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionRepeat animations:^{
            
            self.myView.frame = CGRectMake(0, 200, 375, 130);
                            
        } completion:^(BOOL finished) {
            
        }];
        
     /* 方法5:从一个View过渡到另一个View */
        
        [UIView transitionFromView:self.myView toView:self.redView duration:3 options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) {
            
        }];
    
     /* 方法6:设置弹簧(Spring)相关参数 */
            
        [UIView animateWithDuration:3 delay:0.5 usingSpringWithDamping:0.1 initialSpringVelocity:10 options:UIViewAnimationOptionRepeat animations:^{
                    
            /* 开始动画的状态 UIView的属性  */
            self.myView.frame = CGRectMake(0, 200, 375, 130);
            
        } completion:^(BOOL finished) {
            
            /* 结束动画 UIView的属性*/
            
        }];
    
     }
    
    #pragma mark - Animating Views
    - (IBAction)handleViewTow:(id)sender {
        
        /* 1,开始动画*/
        [UIView beginAnimations:@"FrameChange" context:nil];
                
        /* 2.动画设置 */
        
        [UIView setAnimationDuration:3];
        
        /** 重复的次数*/
        [UIView setAnimationRepeatCount:NSIntegerMax];
        
        /* 延迟动画 */
        
        [UIView setAnimationDelay:0.5];
        self.myView.frame = CGRectMake(0, 200, 375, 130);
        
        /* 3.提交动画 */
        [UIView commitAnimations];
           
    }
  • 相关阅读:
    系统架构设计(通用型)
    主流Java数据库连接池分析(C3P0,DBCP,TomcatPool,BoneCP,Druid)
    JS实现多行文本最后是省略号紧随其后还有个超链接在同一行的需求
    java判断集合是否相等
    JavaScript调试技巧
    linux下出现ping:unknown host www.baidu.com问题时的解决办法——ubuntu下局域网络的配置
    linux网络配置相关命令、虚拟网络接口eth0:0
    网络游戏服务器架构设计
    Linux 下使用静态google protocl buffer
    php-fpm nginx 使用 curl 请求 https 出现 502 错误
  • 原文地址:https://www.cnblogs.com/WJJ-Dream/p/5817126.html
Copyright © 2011-2022 走看看