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

UIButton

2015-07-29 22:35 423 查看
用button自己的便利构造器的方式来创建对象

UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];


指定button的位置和大小

button.frame=CGRectMake(100, 100, 100, 70);


设置背景颜色

button.backgroundColor=[UIColor yellowColor];
[self.window addSubview:button];


// button是便利构造器,不需要release


给button设置标题

[button setTitle:@"确认" forState:UIControlStateNormal];
// 通常情况下,字体显示,点击的时候字体不显示
// 还有disable等状态


设置button标题的字体大小

button.titleLabel.font=[UIFont systemFontOfSize:14];


设置圆角

button.layer.cornerRadius=10;
button.layer.masksToBounds=YES;


设置边框

// 宽度
button.layer.borderWidth=7;
// 颜色
borderColor


点击方法

button最重要的部分

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