码迷,mamicode.com
首页 > 其他好文 > 详细

我的测试

时间:2015-03-14 12:21:41      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:

#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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!