--------------- 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