frame,center,bounds,transform的使用简单的动画执行
来源:互联网 发布:中远网络陈大龙 编辑:程序博客网 时间:2024/06/05 14:58
简介: frame可以改变控件的位置大小,bounds只能修改大小,center只能修改位置,transform都能做,大小,位置,旋转,等
bounds的xy都为0不能修改位置的,他的放大缩小是以center为准的,与frame的不同
center的xy指的控件的中心,
transform
import "ViewController.h"
@interface ViewController ()
@property (weak,nonatomic) IBOutletUIButton *btnIcon;
- (IBAction)move;
- (IBAction)back;
- (IBAction)scale;
- (IBAction)rotate;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)move {
//CGAffineTransform transForm = self.btnIcon.transform;
//self.btnIcon.transform = CGAffineTransformMakeTranslation(0, -50);//--基于当前的位置,x方向平移0,y方向向上平移50,但是只平移一次,以为此时一直是以开始的位置为(0,0)平移的(x,y)--
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:2];
self.btnIcon.transform =CGAffineTransformTranslate(self.btnIcon.transform,0, 50);//--这个是基于每次平移开始前当前的位置发生的 即现在可以连续平移了--
[UIViewcommitAnimations];
}
- (IBAction)back {
self.btnIcon.transform =CGAffineTransformIdentity;//清空之前设置的transform属性
}
- (IBAction)scale {
//self.btnIcon.transform = CGAffineTransformMakeScale(1.2, 1.2);//这个与上面的CGAffineTransformMakeTranslation一样,只基于这一个位置放大 所以要连续放大则需要把当前的 transform传进去
[UIViewanimateWithDuration:2animations:^{
self.btnIcon.transform =CGAffineTransformScale(self.btnIcon.transform,1.2, 1.2);
}];
}
- (IBAction)rotate {
[UIViewbeginAnimations:nilcontext:nil];
[UIViewsetAnimationDuration:2];
self.btnIcon.transform =CGAffineTransformRotate(self.btnIcon.transform,M_PI_4);
//self.btnIcon.transform = CGAffineTransformMakeRotation(M_PI_4); //旋转的origin没有改变过
[UIViewcommitAnimations];
}
//view.transform = CGAffineTransformIdentity;//清空之前设置的transform属性
//1
UIView beginAnimations:nilcontext:nil];
//2
[UIView setAnimationDuration:2];
//----- 这句话是将修改好的控件新属性赋值给控件,
self.btnIcon.frame = originFrame;
//-----1 2分别是,开始执行动画,执行动画的时间,这句话放在这里就是动画要做用的东西,即动画效果作用在控件改变的时候
//3动画执行结束//提交动画
[UIViewcommitAnimations];
//block方式实现更简单
[UIViewanimateWithDuration:1.0animations:^{
self.btnIcon.frame = originFrame;
}];
- frame,center,bounds,transform的使用简单的动画执行
- frame、center、bounds、transform的使用
- frame | center |bounds |transform
- transform和frame bounds center的混合开发
- frame、bounds和center的使用场景
- frame、bounds、center的区别
- frame\bounds\center的区别
- frame\center\bounds的区别
- OC的frame、center、transform
- iOS之旅--使用控件的属性frame、center、bounds
- IOS开发 深入坐标系frame,bounds,center,transform的作用于之间的联系
- IOS开发之深入坐标系frame、bounds、center、 transform的不同与联系
- IOS开发之深入坐标系frame、bounds、center、 transform的不同与联系
- frame,bounds,center的几个关系
- Frame,Bounds的区别,center属性
- Frame,Bounds和Center的区别,联系
- 详解UIView的frame、bounds、center属性
- Transform 与Frame、bounds的个人总结
- atom + activate-power-mode插件 (免FQ集成)
- Android Studio删除项目的步骤
- leetcode Reverse Integer & Reverse a string----重点
- Android绘图基础--简易写字板
- Xcode 7 打包上架过程的处理
- frame,center,bounds,transform的使用简单的动画执行
- Linux大棚版redis入门教程
- Oracle12c及PLSQL Developer安装全程记录
- OSG + Win7 64 + VS2010 环境配置测试 按“s” "w" “h”j键没有相应的问题
- Node.js 缓冲区 Buffer
- DES加密模式原理详解
- 反射(一)---类Class
- Swift 可选类型 ?和!
- Android Studio 2.0--如何使用新模拟器以及Instant Run