博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
020606-05-transform
阅读量:4603 次
发布时间:2019-06-09

本文共 1874 字,大约阅读时间需要 6 分钟。

 

 

////  ViewController.m//  05-transform#import "ViewController.h"@interface ViewController ()@property (nonatomic, strong) UIView *tempView;//@property (nonatomic, assign) CGFloat angle;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];        UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];    [tempView addSubview:[[UISwitch alloc] init]];    tempView.backgroundColor = [UIColor redColor];    tempView.transform = CGAffineTransformMakeRotation(M_PI_4);    [self.view addSubview:tempView];    self.tempView = tempView;}- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {    // 清空transform,以前的平移、缩放、旋转都会消失    [UIView animateWithDuration:2.0 animations:^{        self.tempView.transform = CGAffineTransformIdentity;            }];    //    self.angle += M_PI_4;    //    [UIView animateWithDuration:1.0 animations:^{
//// self.tempView.transform = CGAffineTransformScale(self.tempView.transform, 0.8, 0.8);// self.tempView.transform = CGAffineTransformRotate(self.tempView.transform, M_PI_4);// }]; // transform:形变属性,能完成的功能:平移、缩放、旋转// [UIView animateWithDuration:2.0 animations:^{// // 缩放// self.tempView.transform = CGAffineTransformMakeScale(0.5, 0.5);// // 平移// self.tempView.transform = CGAffineTransformMakeTranslation(-100, 100); // 旋转// self.tempView.transform = CGAffineTransformMakeRotation(-M_PI_4); // CGAffineTransform translation = CGAffineTransformMakeTranslation(-100, 100);// CGAffineTransform scaleTranslation = CGAffineTransformScale(translation, 0.5, 0.5);// CGAffineTransform rotateScaleTranslation = CGAffineTransformRotate(scaleTranslation, M_PI_2);// self.tempView.transform = rotateScaleTranslation;// }];}@end

 

转载于:https://www.cnblogs.com/laugh/p/6508903.html

你可能感兴趣的文章
poj 3764 The xor-longest Path (01 Trie)
查看>>
预备作业01
查看>>
【Spark】Spark-Redis连接池
查看>>
【云计算】使用supervisor管理Docker多进程-ntpd+uwsgi+nginx示例最佳实践
查看>>
Ubuntu16.04下配置ssh免密登录
查看>>
实验二 2
查看>>
will-change属性
查看>>
android学习笔记54——ContentProvider
查看>>
Unity3d android开发之触摸操作识别-双击,滑动去噪处理
查看>>
Custom view * is not using the 2- or 3-argument View constructors; XML attributes will not work
查看>>
模型选择准则
查看>>
安卓动态增加按钮
查看>>
iOS7程序后台运行
查看>>
maven+testng+reportng的pom设置
查看>>
IT telephone interview
查看>>
gitlab安装配置
查看>>
ps载入画笔
查看>>
悲怆:IT人的一声叹息->一个程序员的自白[转帖]
查看>>
[SpringMVC]自定义注解实现控制器访问次数限制
查看>>
日记(序)
查看>>