Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a 1 pixel-wide smooth border on a UIView, with a cornerRadius?

Here is the code I use to setup the border of my UIView:

self.layer.borderColor = [UIColor whiteColor].CGColor;
self.layer.cornerRadius = self.bounds.size.height/2;
self.layer.borderWidth = 0.5;

And this is what it looks like:

enter image description here

The horizontal part is correct, but is there a way of getting the curved parts "smoother" whilst keeping a 1 pixel line width on retina devices? It looks very aliased right now.

Thanks!

like image 888
Joris Mans Avatar asked Dec 04 '25 01:12

Joris Mans


1 Answers

You should change self.layer.borderWidth = 0.5; to self.layer.borderWidth = 1.f;

like image 155
RrrangeTop Avatar answered Dec 06 '25 16:12

RrrangeTop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!