您的位置:首页 > 产品设计 > UI/UE

UIButton

2015-07-30 20:58 393 查看
//用button自己的便利构造器的方式来创建对象

UIButton *button= [UIButton
buttonWithType:UIButtonTypeSystem];

//指定button的位置和大小
button.frame=CGRectMake(100,
100, 150,
70);

//设置背景颜色
button.backgroundColor=[UIColor
cyanColor];
[self.window
addSubview:button];

//button不需要release

//给button设置标题

//通常状态

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

//设置button的字体大小

//
button.titleLabel.font=[UIFont
systemFontOfSize:20];

// //设置圆角

button.layer.cornerRadius=10;

// //设置边框

button.layer.borderWidth=1;

//

// //点击方法,button最重要的部分

[button addTarget:self
action:@selector(click:)
forControlEvents:UIControlEventTouchUpInside];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: