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

9.小项目:按钮头像 版本3.0(纯代码)

时间:2015-08-01 15:31:39      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:

备注:增加了监听按钮的点击的功能  

--------------- ViewController.m ---------------

#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    UIButton *btn  =  [[UIButton  alloc] init];

    btn.frame = CGRectMake(100, 100, 100, 100);

    [btn setBackgroundImage:[UIImage imageNamed:@"btn_01"] forState:UIControlStateNormal];

    [btn setBackgroundImage:[UIImage imageNamed:@"btn_02"] forState:UIControlStateHighlighted];

    [btn setTitle:@"摸我啊" forState:UIControlStateNormal];

    [btn setTitle:@"摸我干嘛" forState:UIControlStateHighlighted];

    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];

    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];//监听

    [self.view addSubview:btn];

}


- (void) btnClick

{

    NSLog(@"btnClick");

}


@end

9.小项目:按钮头像 版本3.0(纯代码)

标签:

原文地址:http://www.cnblogs.com/lixiang2015/p/4694103.html

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