【iOS】UIButton 常用属性
发现 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];
效果如图所示: