How do I animate in/out a gaussian blur effect in iOS?

后端 未结 5 686
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 09:32

For the whole iOS 7 feel, I want to apply a blur effect to a specific portion of the screen to obfuscate it, but I don\'t want to just throw the blur on instantly, I want to

5条回答
  •  一整个雨季
    2020-12-13 10:21

    I've developed a small project that uses GPUImage for live blurring with variable blur radius and framerate (MSLiveBlur) - this sounds like exactly what you need.

    In the sample app I have a slider that increases / decreases the blur level in response to user action, as you mentioned in your question. If you wanted to animate it without user interaction, you could make a timer that slowly increases the blur radius until you reach the final value. You wouldn't be able to use CoreAnimation with this solution though.

    [[MSLiveBlurView sharedInstance] setBlurInterval:0.2];
    [[MSLiveBlurView sharedInstance] blurRect:someView.frame];
    
    // Count x from 0 to your final radius
    [MSLiveBlurView sharedInstance].blurRadius = x;
    

提交回复
热议问题