简体   繁体   English

删除角半径UIButton

[英]Removing corner radius UIButton

I have applied a border and a corner radius to a UIButton in this way: 我以这种方式将边框和拐角半径应用于UIButton:

self.Button3.layer.borderWidth = 10;
self.Button3.clipsToBounds = NO;
[self.Button3.layer setCornerRadius:100.0f];

I wanted to know if there was a way to remove both of them, without doing this: 我想知道是否有一种方法可以不删除这两个对象:

self.Button3.layer.borderWidth = 0;
self.Button3.clipsToBounds = NO;
[self.Button3.layer setCornerRadius:0.0f];

I think that this would only hide, not remove them. 我认为这只会隐藏而不会将其删除。

I think that is the way to go, since CALayer provides no API to "remove" a border other than borderWidth property. 我认为这是要走的路,因为CALayer除了提供borderWidth属性外,没有提供任何API来“删除”边框。 According to the documentation, CALayer just "draws" the border, so, I don't think CALayer holds something like an UIView or UIImage to draw the border. 根据文档, CALayer只是“绘制”边框,因此,我不认为CALayer拥有UIViewUIImage类的东西来绘制边框。

When this value is greater than 0.0, the layer draws a border using the current borderColor value. 当此值大于0.0时,图层使用当前的borderColor值绘制边框。 The border is drawn inset from the receiver's bounds by the value specified in this property. 通过此属性中指定的值从接收者的边界开始绘制边框。 It is composited above the receiver's contents and sublayers and includes the effects of the cornerRadius property. 它在接收者的内容和子层之上进行了合成,并包含cornerRadius属性的效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM