我有一个自定义的 UIView,它通过使用 layer.cornerRadius 来圆角,如下所示:
- (void)layoutSubviews
{
[super layoutSubviews];
self.layer.cornerRadius = self.frame.size.width / 2.0;
self.layer.borderColor = [UIColor whiteColor].CGColor;
self.layer.borderWidth = 2.0;
self.layer.masksToBounds = YES;
self.backgroundColor = [UIColor redColor];
}
如何去掉外面非常细的红圈?
最佳答案
嗯,一种更有效的方法来完成您需要的操作,是将这个函数复制粘贴到自定义 View 的 .m 文件中,并在 drawRect 方法中调用它:
- (void)drawRoundedViewWithFrame: (CGRect)frame color:(UIColor *)color
{
//// roundCircle Drawing
UIBezierPath* roundCirclePath = [UIBezierPath bezierPathWithOvalInRect: frame];
[color setFill];
[roundCirclePath fill];
[UIColor.whiteColor setStroke];
roundCirclePath.lineWidth = 2;
[roundCirclePath stroke];
}
关于ios - 如何在 iOS 7.1.1 中摆脱使用 Layer.cornerRadius 圆角的 UIView 中的细边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23891033/