在UIImageView中绘制一个椭圆或圆

时间:2014-04-15 06:53:21

标签: ios cgrect

我创建了一个图像,我想用参数X坐标,Y坐标,宽度和高度在其上绘制椭圆或圆。我在google上搜索,发现你无法在UI图像视图中绘制。

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tom.jpg"]];

[self.view addSubview:imageView];

我可以在绘制椭圆或圆圈的地方添加模糊滤镜效果吗?

1 个答案:

答案 0 :(得分:1)

请参阅此文章:http://www.appcoda.com/ios-programming-circular-image-calayer/

创建圆形轮廓图像:

self.profileImageView.layer.cornerRadius = self.profileImageView.frame.size.width / 2;
self.profileImageView.clipsToBounds = YES;

添加边框:

self.profileImageView.layer.borderWidth = 3.0f;
self.profileImageView.layer.borderColor = [UIColor whiteColor].CGColor;

创建圆角图像:

self.profileImageView.layer.cornerRadius = 10.0f;