zoukankan      html  css  js  c++  java
  • UI动画效果

    UI界面的动画效果总结

    方式1:头尾式

    //开始动画
    [UIView beginAnimations:nil context:nil];
    //设置动画时间
    [UIView setAnimationDuration:2.0];
    
    /* 需要执行动画的代码 */
    
    //提交动画
    [UIView commitAnimations];
    

    方式2:block式

    [UIView animateWithDuration:2.0 delay:1.0 options:kNilOptions animations:^{
    
        /* 需要执行动画的代码 */
    
    } completion:nil];
    
    // 1s后,再执行动画(动画持续2s)
    
    [UIView animateWithDuration:2.0 delay:1.0 options:kNilOptions animations:^{
    
        /* 需要执行动画的代码 */
    
    } completion:^(BOOL finished){
        /* 动画结束后执行的代码 */
    }];
    

    帧动画

    // 设置动画图片(images 是数组存放的是图片)
    self.imageView.animationImages = images;
    
    // 设置播放次数
    self.imageView.animationRepeatCount = 1;
    
    // 设置图片
    self.imageView.image = [UIImage imageNamed:@"imageName"];
    
    // 设置动画的时间
    self.imageView.animationDuration = image.count * 0.04;
    
    // 开始动画
    [self.imageView startAnimating];
    
    //self.imageView.animationDuration 时间后 执行next方法
    [self performSelector:@selector(next) withObject:nil afterDelay:self.imageView.animationDuration];
    

    更新View动画

    • 让 self.view 以及它的所有子控件强制更新的动画
    //利用 2 秒的时间去更新
    [UIView animateWithDuration:2.0 animations:^{
        [self.view layoutIfneeded];
    }];
  • 相关阅读:
    面试金典——模式匹配
    浅谈C语言中的联合体
    android recovery模式及ROM制作
    模拟键盘输入 : SendMessage, keybd_event, PostKeybdMessage
    在游戏中使用keybd_event的问题
    keybd_event函数用法
    C语言清空输入缓冲区的N种方法对比
    深究“字节对齐”的原因
    字节对齐
    网络安装CentOS 5.3
  • 原文地址:https://www.cnblogs.com/ShaoYinling/p/4603313.html
Copyright © 2011-2022 走看看