我有一个UIView
,UIView
我有UIImageView
&我所做的是将cornerRadius
设置为UIView
并设置borderWidth
,但在UIView
之后我得到差不多1个像素的空间,那么我该如何解决这个问题呢? / p>
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;
您可以查看下方显示1像素间距的图片。
Here is Demo Project Please Check That To - Click Here
属性
答案 0 :(得分:7)
尝试使用它,它将在我的项目中正常工作
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;
答案 1 :(得分:0)