标签:
--------------- ViewController.m ---------------
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *head;
- (IBAction)moveClick:(UIButton *) sender;
- (IBAction)sizeChangeClick:(UIButton *) sender;
- (IBAction)rotateClick:(UIButton *)sender;
@end
@implementation ViewController
- (IBAction)moveClick:(UIButton *) sender
{
CGPoint center = self.head.center;
switch (sender.tag)
{
case 1:
center.y -= 10;
break;
case 2:
center.x += 10;
break;
case 3:
center.y += 10;
break;
case 4:
center.x -= 10;
break;
default:
break;
}
self.head.center = center;
}
- (IBAction)rotateClick:(UIButton *)sender
{
switch (sender.tag)
{
case 5:
self.head.transform = CGAffineTransformRotate(self.head.transform, -M_PI_4);
break;
case 6:
self.head.transform = CGAffineTransformRotate(self.head.transform, M_PI_4);
default:
break;
}
}
- (IBAction)sizeChangeClick:(UIButton *) sender
{
CGRect bounds = self.head.bounds;
switch (sender.tag)
{
case 7:
bounds.size.width += 10;
bounds.size.height += 10;
break;
case 8:
bounds.size.width -= 10;
bounds.size.height -= 10;
break;
default:
break;
}
self.head.bounds = bounds;
}
@end
5.小项目:摸我干啥!(位置:center 大小:bounds)
标签:
原文地址:http://www.cnblogs.com/lixiang2015/p/4684222.html