简体   繁体   English

查看角半径问题

[英]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? 我有一个UIView ,在UIView我有UIImageView &我所做的是将cornerRadius设置为UIView并设置borderWidth但是在UIView之后我得到了近1个像素空间所以我该如何解决这个问题?

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. 您可以查看下面显示1像素间距的图像。

Here is Demo Project Please Check That To - Click Here 这是演示项目请检查 - 点击这里

Here how my view look like 这是我的观点的样子 在此输入图像描述

Here is what i want 这就是我想要的 在此输入图像描述

Properties 属性

在此输入图像描述

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;

Try this its work fine... i change in your project . 试试这个工作正常......我改变你的项目。 give me your email id i will send you. 给我你的电子邮件ID我会发给你。

_view1.layer.cornerRadius = _view1.frame.size.height / 2;
_view1.layer.masksToBounds = YES;
_view1.layer.borderColor = [UIColor whiteColor].CGColor;
_view1.layer.borderWidth = 20;

_img.layer.cornerRadius = _img.frame.size.height / 2 ;
_img.clipsToBounds = YES;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM