CIGaussianBlur image size

前端 未结 3 1345
误落风尘
误落风尘 2020-12-28 09:07

I want to blur my view, and I use this code:

//Get a UIImage from the UIView
NSLog(@"blur capture");
UIGraphicsBeginImageContext(BlurContrainerView.         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-28 09:35

    Looks like the blur filter is giving you back an image that’s bigger than the one you started with, which makes sense since pixels at the edges are getting blurred out past them. The easiest solution would probably be to make newView use a contentMode of UIViewContentModeCenter so it doesn’t try to squash the blurred image down; you could also crop blurredImage by drawing it in the center of a new context of the appropriate size, but you don’t really need to.

提交回复
热议问题