UI 动画之反射变换的平移
2015-10-06 19:26
453 查看
@interface
ViewController ()
//准备一个用于动画的UIView
@property(nonatomic,strong)UILabel *customLabel;
//静止,用来对比
@property(nonatomic,strong)UIView *staticView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
//动画影响的属性:frame、center、bounds、background、alpha、transform、
//定义好自定义label
self.customLabel = [[UILabelalloc]initWithFrame:CGRectMake(0,0,
100,100)];
_customLabel.backgroundColor = [UIColormagentaColor];
_customLabel.center =self.view.center;
[self.viewaddSubview:_customLabel];
self.view.backgroundColor = [UIColorcyanColor];
//加一个可以对比的视图,可以直观的看出动画效果。
self.staticView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,
100,100)];
_staticView.center =self.view.center;
_staticView.backgroundColor = [UIColorpurpleColor];
[self.viewinsertSubview:_staticViewbelowSubview:_customLabel];
}
#pragma mark 模拟
动画
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//开启动画之旅
[UILabelbeginAnimations:nilcontext:nil];
//之间就是定义动画
//切圆角
[_customLabel.layersetCornerRadius:50];
[_customLabel.layersetMasksToBounds:YES];
#pragma mark 平移
//三选一 :建议用第三种。
//在初始状态平移
//第一种:最繁琐
_customLabel.transform =CGAffineTransformMake(1,0,
0, 1,
34, 23);
//第二种,稍微好点
_customLabel.transform =CGAffineTransformMakeTranslation(50,50);
//第三种:灵活
//在上一次的基础上平移
_customLabel.transform =CGAffineTransformTranslate(_customLabel.transform,12,
30);
//提交动画
[UILabelcommitAnimations];
}
ViewController ()
//准备一个用于动画的UIView
@property(nonatomic,strong)UILabel *customLabel;
//静止,用来对比
@property(nonatomic,strong)UIView *staticView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
//动画影响的属性:frame、center、bounds、background、alpha、transform、
//定义好自定义label
self.customLabel = [[UILabelalloc]initWithFrame:CGRectMake(0,0,
100,100)];
_customLabel.backgroundColor = [UIColormagentaColor];
_customLabel.center =self.view.center;
[self.viewaddSubview:_customLabel];
self.view.backgroundColor = [UIColorcyanColor];
//加一个可以对比的视图,可以直观的看出动画效果。
self.staticView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,
100,100)];
_staticView.center =self.view.center;
_staticView.backgroundColor = [UIColorpurpleColor];
[self.viewinsertSubview:_staticViewbelowSubview:_customLabel];
}
#pragma mark 模拟
动画
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//开启动画之旅
[UILabelbeginAnimations:nilcontext:nil];
//之间就是定义动画
//切圆角
[_customLabel.layersetCornerRadius:50];
[_customLabel.layersetMasksToBounds:YES];
#pragma mark 平移
//三选一 :建议用第三种。
//在初始状态平移
//第一种:最繁琐
_customLabel.transform =CGAffineTransformMake(1,0,
0, 1,
34, 23);
//第二种,稍微好点
_customLabel.transform =CGAffineTransformMakeTranslation(50,50);
//第三种:灵活
//在上一次的基础上平移
_customLabel.transform =CGAffineTransformTranslate(_customLabel.transform,12,
30);
//提交动画
[UILabelcommitAnimations];
}
相关文章推荐
- UIsearchBar
- SpriteBuilder中本地化的局限性
- SpriteBuilder中本地化的局限性
- SpriteBuilder中本地化的局限性
- UI13_Block传值练习
- UI13_Block
- 两个Arduino之间进行串口通信出错的原因
- android UI界面设计(2)
- 关于@RequestBody 不能json to pojo
- iOS开发UI篇—IOS开发中Xcode的一些使用技巧
- ios图片等比例自适应UIImageview
- Android:Material Design(四) UI控件
- [译] --- GPUImage README.md
- UGUI学习笔记6——官方教程Draggable Panel练习
- StringBuffer StringBuilder
- 关于ios9中得AddressBook和AddressBookUI框架过时问题
- IOS开发UI进阶之UITableView三
- UE删除掉所有的重复行
- UEFI工程编译命令Build用法
- iOS UITableView