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

iOS开发 Button自定义

时间:2015-09-04 18:32:16      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

 - (void)viewDidLoad {

    [super viewDidLoad];   

 

    //自定义button控件

    UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];

    //设置button的位置和大小

    [button setFrame:CGRectMake(50, 100, 50, 100)];

    //设置button的文字

    [button setTitle:@"确定" forState:UIControlStateNormal];

    //设置背景的颜色

    button.backgroundColor=[UIColor blueColor];

    //绑定动作

    [button addTarget:self action:@selector(clickConfirm) forControlEvents:UIControlEventTouchUpInside];

    // 添加到视图中

    [self.view addSubview:button];

 

-(void) clickConfirm{

self.lblTitle.text=@"test";

}

iOS开发 Button自定义

标签:

原文地址:http://www.cnblogs.com/laugher/p/4781984.html

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