Git Product home page Git Product logo

anblurredimageview's Introduction

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.

License

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

anblurredimageview's People

Contributors

aaronn avatar nachosoto avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.