Skip to content
项目

aaronn/ANBlurredImageView

在 GitHub 查看

关于

为 UIImageView 提供动画模糊进入和模糊退出效果。

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

ANBlurredImageView

Subclass of UIImageView for animating the blurring and unblurring of images with a tint color. Useful for quick transitions and bringing focus to the foreground.

Blurred View

Installation

Drag the following files into your project. Made to work with iOS7+.

ANBlurredImageView.h
ANBlurredImageView.m
UIImage+BoxBlur.h
UIImage+BoxBlur.m

Usage

This was made for fast transitions and builds on top of UIImageView's startAnimation and stopAnimation.

Default values are as follows:

frameCount = 5; // Number of frames, 
blurTintColor =  [UIColor clearColor]; // If an alpha is specified, starts at 0 alpha and works its way up to the alpha value with each frame.
blurAmount = 0.1f; // Takes between 0 and 1.

Blur your image by calling any of the following on your imageView:

-(void)blurInAnimationWithDuration:(CGFloat)duration;
-(void)blurOutAnimationWithDuration:(CGFloat)duration;
-(void)blurInAnimationWithDuration:(CGFloat)duration completion:(void(^)())completion;
-(void)blurOutAnimationWithDuration:(CGFloat)duration completion:(void(^)())completion;

Set all your values as early as possible, ideally in the superview's viewDidload. Since we're calculating frames, any change to the frameCount, blurTintColor, blurAmount or the image after the view has loaded requires that you call the following method to ensure your changes are processed.

-(void)generateBlurFramesWithCompletion:(void(^)())completion;

Demo

Demo shows normal blurring, tinted blurring and unblurring. The demo uses more frames than you might need, so switching between normal blur and tinted blurring takes some time to recalculate the frames based on image size and frame count.

Credits

The image box blur algorithm is from IndieAmbitions Blog. UIImage category is modified from ios-relatimeblur.

Follow me on Twitter at @aaronykng.

License

Do whatever you'd like. I'd appreciate a link back and a mention if you use it though!

探索相关项目

加载中…