UIImage在石英光滑的圆angular

我只是testing下面的代码来在UIImage上四舍五入:

- (UIImage *)makeRoundedImage:(UIImage *)image radius:(float)radius; { CALayer *imageLayer = [CALayer layer]; imageLayer.frame = CGRectMake(0, 0, image.size.width, image.size.height); imageLayer.contents = (id) image.CGImage; imageLayer.masksToBounds = YES; imageLayer.cornerRadius = radius; UIGraphicsBeginImageContext(image.size); [imageLayer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return roundedImage; } 

除非仔细观察生成的图像,否则我看起来很好。 angular落不光滑。 我怎样才能使angular落更平滑/柔和?

编辑:

处理图像与石英圆angular:

在这里输入图像说明

就像你可以看到angular落不光滑。

这是UIImageView的cornerRadius更平滑的版本。

在这里输入图像说明

渔获在哪里?

这里是UIImage类别:

 - (UIImage *) imageWithRoundedCornersRadius: (float) radius { // Begin a new image that will be the new image with the rounded corners UIGraphicsBeginImageContextWithOptions(self.size, NO, 0); // Add a clip before drawing anything, in the shape of an rounded rect CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height); [[UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius] addClip]; // Draw your image [self drawInRect:rect]; // Get the image, here setting the UIImageView image UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext(); // Lets forget about that we were drawing UIGraphicsEndImageContext(); return roundedImage; }