码迷,mamicode.com
首页 > 移动开发 > 详细

iOS-按钮的代码封装

时间:2015-07-28 17:55:43      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

//
//  ViewController.m
//  MovePicture
//
//  Created by YaguangZhu on 15/7/28.
//  Copyright (c) 2015年 YaguangZhu. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
- (IBAction)move:(UIButton *)sender;
- (IBAction)scale:(UIButton *)sender;



@property (weak, nonatomic) IBOutlet UIButton *btnIcon;

@end

@implementation ViewController

- (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.
}


- (IBAction)move:(UIButton *)sender {
    //NSLog(@"sss");
    CGRect originFrame = self.btnIcon.frame;
        switch (sender.tag) {
        case 10:
                NSLog(@"up");
                originFrame.origin.y -=10;
            break;
         case 20:
                NSLog(@"right");
                originFrame.origin.x +=10;
            break;
          case 30:
                NSLog(@"down");
                originFrame.origin.y +=10;
                break;
          case 40:
                NSLog(@"left");
                originFrame.origin.x -=10;
                break;
        default:
            break;
    }
}

- (IBAction)scale:(UIButton *)sender {
    CGRect originFrame = self.btnIcon.frame;
    if (sender.tag == 100) {
        originFrame.size.width +=10;
        originFrame.size.height +=10;
        
    }else
    {
        originFrame.size.width -=10;
        originFrame.size.height -=10;
    }

}


@end

 

iOS-按钮的代码封装

标签:

原文地址:http://www.cnblogs.com/zhuyaguang/p/4683329.html

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