Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border has background color seeping through it [duplicate]

I'm setting the background color to a white border and the border is seeping through the background.I'm looking to have the blue line gone. Can you please suggest a solution to this problem?

Here is my code below. And there is an image of what I'm talking about below.

[Border example Image

self.imageView.layer.borderColor = UIColor.white.cgColor
self.imageView.layer.borderWidth = 3
self.imageView.backgroundColor = UIColor.blue
self.imageView.layer.cornerRadius = CGFloat(CircleDiameter/2)
like image 764
john Avatar asked Oct 18 '22 12:10

john


1 Answers

I guess this is what iOS rendering do with a layer have positive cornerRadius, I have Tested add a white circle view overlap a blue circle view which has the same size, the same situation appears:

enter image description here

In fact, through borderWidth Document the border of layer is drawn inset from the receiver’s bounds, so it has the same kind of situation as I mentioned above:

When this value is greater than 0.0, the layer draws a border using the current borderColor value. 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.

So borders + roundness = sadness on iOS and I think you need another way to implement your design.

like image 81
Mike Qiu Avatar answered Oct 20 '22 04:10

Mike Qiu