Luk*_*uke 6 objective-c uibutton cglayer ios
我正在UIButton使用1px xpp图像更改通过此类别方法的背景颜色:
- (void)setBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0);
[backgroundColor setFill];
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, 1, 1));
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
[self setBackgroundImage:backgroundImage forState:state];
UIGraphicsEndImageContext();
}
Run Code Online (Sandbox Code Playgroud)
但是,这会覆盖我的设置.layer.cornerRadius.我需要一个带圆角的按钮,但也需要一个可以突出显示的背景颜色.
有什么方法吗?角半径需要是动态的.
| 归档时间: |
|
| 查看次数: |
1648 次 |
| 最近记录: |