Blur UIImage outside of bounds (Photoshop-style)

前端 未结 2 461
深忆病人
深忆病人 2021-02-09 00:30

I\'m trying to do a Gaussian blur on a UIImage that replicates my photoshop mockup.

Desired Behavior: In Photoshop, when I run a Gaussian blur filter,

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-09 00:39

    Try resizing the UIImageView's bounds to adjust to the blur. A view will clip what is outside of its bounds. Note that in your example, the box blurred in photoshop looks to be about 20% larger than the original image.

    UIImageView *image;
    image.layer.bounds = CGRectMake(0, 
                                    0, 
                                    image.layer.bounds.size.width + 5, 
                                    image.layer.bounds.size.height + 5); 
    

提交回复
热议问题