标签:
#import "ViewController.h" @interface ViewController () -(IBAction)move:(UIButton *)btn; -(IBAction)big; -(IBAction)small; -(IBAction)leftRotata; -(IBAction)rightRotata; //头像 @property (nonatomic,weak) IBOutlet UIButton *head; @end @implementation ViewController #pragma mark 移动 -(void)move:(UIButton *)btn{ //1.取出原来的属性 CGRect tempF = self.head.frame; //2,修改原来的属性 CGFloat delta = 10; switch (btn.tag) { case 1://上 tempF.origin.y -= delta; break; case 2://下 tempF.origin.y += delta; break; case 3://左 tempF.origin.x -= delta; break; case 4://右 tempF.origin.x += delta; break; } //3,重新复制 self.head.frame = tempF; } #pragma mark 放大 -(IBAction)big{ //取出原来的属性; CGRect tempf = self.head.frame; //改变size属性 tempf.size.height += 10; tempf.size.width += 10; //赋值 self.head.frame = tempf; } #pragma mark 缩小 -(IBAction)small{ //取出原来的值 CGRect tempFrame = self.head.frame; //改变属性 tempFrame.size.height -= 10; tempFrame.size.width -= 10; //把临时frame赋值回去 self.head.frame = tempFrame; } #pragma mark 左旋转 -(IBAction)leftRotata{ //1取得头像 UIButton *head = (UIButton *)[self.view viewWithTag:10]; //2想左旋转45度 //角度是正数:顺时针 角度是负数:逆时针 //head.transform = CGAffineTransformMakeRotation(-M_PI_4); head.transform = CGAffineTransformRotate(head.transform, -M_PI_4); } #pragma mark 右旋转 -(IBAction)rightRotata{ //1取得头像 UIButton *head = (UIButton *)[self.view viewWithTag:10]; //2想左旋转45度 //角度是正数:顺时针 角度是负数:逆时针 //head.transform = CGAffineTransformMakeRotation(-M_PI_4); head.transform = CGAffineTransformRotate(head.transform, M_PI_4); } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
而我的v
标签:
原文地址:http://www.cnblogs.com/dugutaiyi/p/4337297.html