简体   繁体   English

如何对图像进行圆角处理

[英]how to round corner of an image

In order to round the corner of an image, I am doing the following为了绕过图像的角落,我正在做以下事情

UIImageView     *myView     =   [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[myView setImage:[UIImage imageNamed:@"xcode_57X57"]];
myView.layer.cornerRadius      =   10.0;
myView.layer.borderWidth       =   1.0;
myView.layer.borderColor       =   [UIColor blueColor].CGColor;
myView.layer.shadowRadius      =   8;

However, what I got is the corners of myView are rounded but the corners of an image.但是,我得到的是 myView 的角是圆的,但图像的角是圆的。 The image below shows my issue.下图显示了我的问题。

If you encountered this problem before, please advice me on this.如果您以前遇到过这个问题,请就此向我提出建议。

在此处输入图像描述

You need to clip subviews:您需要剪辑子视图:

myView.clipsToBounds = TRUE;

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

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