您的位置:首页 > 其它

控件的平移旋转缩放transform

2016-06-05 00:00 337 查看
摘要: 控件的平移旋转缩放transform

控件的平移旋转缩放

####1.控件的平移

@interface ViewController ()
@property (nonatomic,strong) UIView *tempView;
@end

- (void)viewDidLoad {
[super viewDidLoad];
self.tempView=[[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];
self.tempView.backgroundColor=[UIColor redColor];
[self.view addSubview:self.tempView];
}

-(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
self.tempView.transform=CGAffineTransformMakeTranslation(50, 50);
}

####2.控件的旋转

-(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//self.tempView.transform=CGAffineTransformMakeTranslation(50, 50);
[UIView animateWithDuration:1.0 animations:^{
self.tempView.transform=CGAffineTransformMakeRotation(M_PI_4);
}];

}

####3.控件的缩放

-(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//self.tempView.transform=CGAffineTransformMakeTranslation(50, 50);
[UIView animateWithDuration:1.0 animations:^{
self.tempView.transform=CGAffineTransformMakeScale(0.5, 0.5);
}];

}

####4.控件的平移旋转缩放

-(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//self.tempView.transform=CGAffineTransformMakeTranslation(50, 50);
[UIView animateWithDuration:1.0 animations:^{
//同时进行两种transform
CGAffineTransform transform=CGAffineTransformMakeTranslation(50, 50);
CGAffineTransform scaleTransform=CGAffineTransformScale(transform, 0.5, 0.5);
self.tempView.transform=scaleTransform;

}];
self.tempView.transform=CGAffineTransformIdentity;
}

####5.github

github
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息