您的位置:首页 > 产品设计 > UI/UE

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动画的方式,块动画具有以下优势

可以在动画完成时做一些其他的任务

可以设置动画延迟及动画效果选项

快动画支持嵌套
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: