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

UIView Animation 与 CACoreAnimation

时间:2015-09-09 11:18:35      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

UIViewAnimation 与 CACoreAnimation

 1 定义:

  他是一个初步的文档的API或技术在动画提供流体可视化用户界面的不同状态之间的转换。在iOS,动画是广泛使用重新定位观点,改变它们的大小,把他们从视图层次结构,并隐藏它们。您可以使用动画来传达反馈给用户或实现有趣的视觉效果。

  在iOS,创建复杂的动画不需要编写任何代码。本章中描述的所有的动画技术使用提供的内置支持核心动画。所有你要做的就是触发动画,让核心动画处理单个帧的渲染。这使得创建复杂的动画很简单只有几行代码。

 

 2 UIViewAnimation 的使用:  

  能通过UIViewAnimation执行的动画属性有:frame , bounds , centertransform , alpha , backgroundColorcontentStretch

 

    (2.1) UIViewAnimation 操作UIview frame 属性:  

#import "AnimationViewController.h"

@interface AnimationViewController ()


@property (nonatomic, strong) UIButton *frameAnimationButton;

@end

@implementation AnimationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.frameAnimationButton =  [[UIButton alloc]init];
    self.frameAnimationButton.frame = CGRectMake(100, 100, 100, 100);
    self.frameAnimationButton.backgroundColor = [UIColor redColor];
    [self.frameAnimationButton addTarget:self action:@selector(doFrameAnination) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:self.frameAnimationButton];
    
}

// 点击执行Frame动画 刚开始的frame (100, 100, 100, 100) 点击以后执行动画 2秒内修改成 (200, 200, 50, 50) 动画执行完成后回到原点
- (void)doFrameAnination
{
    
    [UIView animateWithDuration:2 animations:^{
        self.frameAnimationButton.frame = CGRectMake(200, 200, 50, 50);
    } completion:^(BOOL finished) {
        self.frameAnimationButton.frame = CGRectMake(100, 100, 100, 100);
    }];
}

@end

 

 

 

  

  

UIView Animation 与 CACoreAnimation

标签:

原文地址:http://www.cnblogs.com/ethan0000/p/4793757.html

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