【发布时间】:2014-09-10 12:03:09
【问题描述】:
我有一个 UIImageView,我只想模糊图像的底部。 有人可以帮我吗?
我使用 UIImage + ImageEffects 类别来完全模糊图像。如何仅针对特定部分执行此操作?
【问题讨论】:
标签: ios uiimageview uiimage gradient
我有一个 UIImageView,我只想模糊图像的底部。 有人可以帮我吗?
我使用 UIImage + ImageEffects 类别来完全模糊图像。如何仅针对特定部分执行此操作?
【问题讨论】:
标签: ios uiimageview uiimage gradient
将您的 UIImage 拆分为两个 UIImage。模糊你想要的一个,让另一个不受影响。下面将图像精确地在中心分割,如果要移动模糊部分,请在 CGImageCreateWithImageInRect 调用中调整矩形。
UIImage *image = [UIImage imageNamed:@"yourImage.png"];
CGFloat halfImageHeight = image.size.height / 2.f;
CGImageRef topImgRef = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, 0, image.size.width, halfImageHeight));
UIImage *topImage = [UIImage imageWithCGImage:topImgRef];
CGImageRelease(topImgRef);
CGImageRef bottomImgRef = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, halfImageHeight, image.size.width, halfImageHeight));
UIImage *bottomImage = [UIImage imageWithCGImage:bottomImgRef];
CGImageRelease(bottomImgRef);
// Add blur effects to bottomImage
【讨论】: