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

【iOS】UIButton 常用属性

2016-06-13 15:00 405 查看
发现 UIButton 的相关属性不熟悉了……常用的一些属性代码如下:

   UIButton *add = [UIButton buttonWithType:UIButtonTypeCustom];
add.frame = CGRectMake(WIDTH-80, 20, 60, 30);
add.layer.masksToBounds = YES;
add.layer.cornerRadius = 8.0;
add.layer.borderWidth = 1.0; //边框宽度
add.backgroundColor = [UIColor whiteColor];
//    add.titleLabel.backgroundColor = [UIColor blueColor];

[add setTitle:@"Add" forState:UIControlStateNormal];
[add setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[self.view addSubview:add];
[add addTarget:self action:@selector(addSth) forControlEvents:UIControlEventTouchUpInside];


效果如图所示:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: