iOS学习(frame、bounds、center:)以及UIView的旋转,平移和缩放
2015-07-28 20:36
603 查看
1.
frame、bounds、center:
frame:是以父视图的左上角为坐标原点,它是控件所在矩形框的位置和尺寸
bounds:同是为控件所在矩形框位置和尺寸,但是它是以自己左上角作为自己的位置和尺寸因此他的x.y坐标始终是0
center:控件中点的位置
2.UIView
旋转
transform:控件的形变属性(可以用来设置旋转角度,比例素放,平移操作)
获取v
UIView *v = (UIView *)[self.view
viewWithTag:100];
CGAffineTransform transform;
旋转
transform =
CGAffineTransformRotate(v.transform,
M_PI_4);(此处更改为平移语句或者其他移动语句即可)
设置动画开始的
[UIView
beginAnimations:nil
context:nil];
设置动画持续的时间
[UIView
setAnimationDuration:.1f];
定义动画效果
[UIView
animateWithDuration:2.0f
animations:^{
v.transform = transform;
}completion:^(BOOL finished){
[UIView
animateWithDuration:1.0f
animations:^{
设置转一次之后的背景颜色
v.backgroundColor = [UIColor
yellowColor];
设置透明度
v.alpha =
1.0f;
}];
}];
平移:
transform = CGAffineTransformMakeTranslation(10.0,
300.0);
缩放:放大或者放小,根据自己设置的参数,这里是放大
transform = CGAffineTransformScale(v.transform,
2, 4);
3.UIView:封装了三个动画方法
[UIView animateWithDuration: animations: completion:]
[UIView animateWithDuration: animations:]
[UIView animateWithDuration: delay:option:animations:completion:]
对比beginAnimations动画的方式,块动画具有以下优势
可以在动画完成时做一些其他的任务
可以设置动画延迟及动画效果选项
快动画支持嵌套
frame、bounds、center:
frame:是以父视图的左上角为坐标原点,它是控件所在矩形框的位置和尺寸
bounds:同是为控件所在矩形框位置和尺寸,但是它是以自己左上角作为自己的位置和尺寸因此他的x.y坐标始终是0
center:控件中点的位置
2.UIView
旋转
transform:控件的形变属性(可以用来设置旋转角度,比例素放,平移操作)
获取v
UIView *v = (UIView *)[self.view
viewWithTag:100];
CGAffineTransform transform;
旋转
transform =
CGAffineTransformRotate(v.transform,
M_PI_4);(此处更改为平移语句或者其他移动语句即可)
设置动画开始的
[UIView
beginAnimations:nil
context:nil];
设置动画持续的时间
[UIView
setAnimationDuration:.1f];
定义动画效果
[UIView
animateWithDuration:2.0f
animations:^{
v.transform = transform;
}completion:^(BOOL finished){
[UIView
animateWithDuration:1.0f
animations:^{
设置转一次之后的背景颜色
v.backgroundColor = [UIColor
yellowColor];
设置透明度
v.alpha =
1.0f;
}];
}];
平移:
transform = CGAffineTransformMakeTranslation(10.0,
300.0);
缩放:放大或者放小,根据自己设置的参数,这里是放大
transform = CGAffineTransformScale(v.transform,
2, 4);
3.UIView:封装了三个动画方法
[UIView animateWithDuration: animations: completion:]
[UIView animateWithDuration: animations:]
[UIView animateWithDuration: delay:option:animations:completion:]
对比beginAnimations动画的方式,块动画具有以下优势
可以在动画完成时做一些其他的任务
可以设置动画延迟及动画效果选项
快动画支持嵌套
相关文章推荐
- hdu 5288 OO’s Sequence(two point + rmq)
- UI__UIGestureRecognize
- Snail—UI学习之代理传值Delegate
- 获取进程CPU占用率 -- NtQuerySystemInformation
- 暴力求解——Equivalent Strings
- How to convert Windows 7 on MBR/BIOS to GPT/UEFI
- ANDROID STDUIO 项目里的R文件突然丢失的解决办法N种之一
- UVA120istringstream和deque的用法
- IOS--UI--LessonFMDB
- iOS UILabel的输出自适应高度设置
- 终于搞定UIScrollView上的几个tableview和collection view之间切换的问题了
- Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the
- Codeforces Gym100571A Cursed Query
- iOS 获取联系人,并调用系统地址簿UI
- 【读书笔记】UIWindow-密码框
- 【读书笔记】UIWindow-密码框
- IOS--UI--LessonDataBase
- UIAlertController的使用二
- 【IOS】 遍历info 所有内容 && 唯一的节能设备UUID
- iOS 在UILabel显示不同的字体和颜色(转)