IOS-官方文档CGAffineTransform(旋转,缩放,平移)

来源:互联网 发布:系统编程 编辑:程序博客网 时间:2024/05/16 16:11

1.旋转
方法原型

CGAffineTransform CGAffineTransformMakeRotation ( CGFloat angle );//旋转

代码实例

self.view.backgroundColor = [UIColor whiteColor];    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 55, 20)];    title.center = CGPointMake(100,200);    title.text = @"公告";    title.textColor = [UIColor redColor];    title.font = [UIFont systemFontOfSize:10.0f];    title.textAlignment = NSTextAlignmentCenter;    [self.view addSubview:title];    [UIView animateWithDuration:3.0                     animations:^{                         title.transform = CGAffineTransformRotate(CGAffineTransformScale(title.transform, 1.5, 1.5), -0.2*M_PI); //缩放+旋转                     }];

2.缩放
方法原型

CGAffineTransform CGAffineTransformMakeScale ( CGFloat sx, CGFloat sy );//缩放

代码实例

View animateWithDuration:3.0                     animations:^{                         title.transform=CGAffineTransformScale(title.transform, 1.0, 2.0); //实现的是放大和缩小                     }];

3.平移
方法原型

CGAffineTransform CGAffineTransformMakeTranslation ( CGFloat tx, CGFloat ty ); //平移

代码实例

[UIView animateWithDuration:3.0                     animations:^{                         title.transform=CGAffineTransformTranslate(title.transform, 20, 20); //平移                     }];
0 0
原创粉丝点击