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

5.小项目:摸我干啥!(位置:center 大小:bounds)

时间:2015-07-28 22:34:17      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

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

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