Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View Corner Radius Issue

i have one UIView and in that UIView i have UIImageView & what i have done is set cornerRadius to that UIView and also set borderWidth but i get nearly about 1 pixel space after that UIView so how can i fix that issue?

view1.clipsToBounds = YES;
view1.layer.cornerRadius = 150;
view1.layer.masksToBounds = YES;
view1.layer.borderColor = [UIColor whiteColor].CGColor;
view1.layer.borderWidth = 50;
view1.layer.opaque = NO;

You can check below image that show 1 pixel spacing.

Here is Demo Project Please Check That To - Click Here

Here how my view look like enter image description here

Here is what i want enter image description here

Properties

enter image description here

like image 477
Bhavin Chauhan Avatar asked Oct 05 '16 10:10

Bhavin Chauhan


1 Answers

try using this it will work fine in my project

self.view1.layer.cornerRadius=_slider1.value;//Value as per your requirement

CALayer *borderLayer = [CALayer layer];
CGRect borderFrame = CGRectInset(CGRectZero,-1,-1);
[borderLayer setBackgroundColor:[[UIColor clearColor] CGColor]];
[borderLayer setFrame:borderFrame];
[borderLayer setCornerRadius:_slider1.value];//Value as per your requirement
[borderLayer setBorderWidth:_slider2.value];//Value as per your requirement
[borderLayer setBorderColor:[[UIColor whiteColor] CGColor]];
[self.view1.layer addSublayer:borderLayer];

self.view1.clipsToBounds=YES;
like image 182
PinkeshGjr Avatar answered Sep 30 '22 06:09

PinkeshGjr