标签:
--------------- ViewController.m ---------------
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *head;
- (IBAction)moveClick:(UIButton *) sender;
- (IBAction)rotateClick:(UIButton *) sender;
- (IBAction)sizeChangeClick:(UIButton *) sender;
@end
@implementation ViewController
- (IBAction)moveClick:(UIButton *) sender
{
CGRect frame = self.head.frame;
switch (sender.tag)
{
case 1:
frame.origin.y -= 10;
break;
case 2:
frame.origin.x += 10;
break;
case 3:
frame.origin.y += 10;
break;
case 4:
frame.origin.x -= 10;
break;
default:
break;
}
self.head.frame = frame;
}
- (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 frame = self.head.frame;
switch (sender.tag) {
case 7:
frame.size.width += 10;
frame.size.height += 10;
break;
case 8:
frame.size.width -= 10;
frame.size.height -= 10;
break;
default:
break;
}
self.head.frame = frame;
}
@end
标签:
原文地址:http://www.cnblogs.com/lixiang2015/p/4684172.html