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

UIButton控件

时间:2014-08-06 17:41:01      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:style   color   io   for   ar   cti   log   type   

-(void)viewDidLoad{

//初始化

self.btn1 = [UIBotton buttonWithType:UIButtonTypeRoundedRect];

//设置大小

self.btn1.frame = CGRectMake(20,20,100,50);

//设置标题

[self.btn1 setTitle:@"Hello" forState:UIControlStateNormal];

//添加点击事件

[self.btn1 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];

//呈现控件

[self.view addSubView:self.btn1];

}

//按钮的点击事件

-(IBAction) click:(id)sender

{

  UIButton * button = (UIButton*)sender;

  NSString *title = btn.titleLabel.text;

  NSLog(@"%@",title);

}

UIButton控件,布布扣,bubuko.com

UIButton控件

标签:style   color   io   for   ar   cti   log   type   

原文地址:http://www.cnblogs.com/AngryCooder/p/3894518.html

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