0
我有一個UIImageView,我只想模糊圖像的底部。 有人可以幫助我嗎?模糊UIImage的特定部分
我已經使用UIImage + ImageEffects類來完全模糊圖像。我怎樣才能爲特定的部分做到這一點?
我有一個UIImageView,我只想模糊圖像的底部。 有人可以幫助我嗎?模糊UIImage的特定部分
我已經使用UIImage + ImageEffects類來完全模糊圖像。我怎樣才能爲特定的部分做到這一點?
將你的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