Coder Social home page Coder Social logo

afblursegue's Introduction

AFBlurSegue

alt text Now supports iOS 8 real time blur and rotation

AFBlurSegue is a UIStoryboardSegue custom implementation that will blur the background of your modal view controller automatically.

alt text

##Installation

alt text

If you're using CocoaPods, just add this line to your Podfile:

pod 'AFBlurSegue', '~> 1.2.1'

If you're not, import these files to your project:

AFBlurSegue.h
AFBlurSegue.m
UIImage+ImageEffects.h
UIImage+ImageEffects.h

##Usage

Since it's a Storyboard Segue custom implementation, you can start using it right from Storyboard. If you have your segue already created, just change it to Custom and the set AFBlurSegue as segue class.

alt text

If you have to create your segue, create a new one by holding right click from the inital view controller to the destination view controller. It will appear a box like on the image below. Select "blur" and it will automatically will asign AFBlurSegue as segue class. Then set an identifier to the segue.

alt text

For presenting the view controller, call -performSegueWithIdentifier:sender::

[self performSegueWithIdentifier:@"blurSegue" sender:self];

Customization (not available from iOS 8 or above, because native blurring is used)

You can customize a few things such as the blur radius, tint color, saturation delta factor and modal transition style. To do this, import the class into your class:

#import "AFBlurSegue.h"

For customizing it, let's use -prepareForSegue:sender:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

	UIViewController *destination = segue.destinationViewController;
	destination.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

	AFBlurSegue *blurSegue = (AFBlurSegue *)segue;
	blurSegue.blurRadius = 20;
	blurSegue.tintColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.1];
	blurSegue.saturationDeltaFactor = 0.5;
}

I highly recommend using UIModalTransitionStyleCrossDissolve or UIModalTransitionCoverVertical for better results. These animations looks really great with the blur effect.

##Blur method

Since there's no public API already for blur effect, we have to find some workarounds. A lot of blurring classes are currently using the famous UIToolbar hack. Since UIToolbar have native blur, you can change its size and use it as a blur container. AFBlurSegue uses the UIImage+ImageEffects class provided by Apple.

##License AFBlurSegue is under MIT license so feel free to use it!

##Author Made by Alvaro Franco. If you have any question, feel free to drop me a line at [email protected]

afblursegue's People

Contributors

adambco avatar alvarofranco avatar fjaguero avatar zhukn1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

afblursegue's Issues

Unable to customise segue in iOS 8

Updated values in prepareForSegue:sender: however, changes for blur radius, tint colour or saturation delta factor are not reflected in iOS 8.

New update to fix rotation doesn't work for iOS 7

When I run the demo of the new update under iOS 7.1, you can see that after bringing up the modal view controller, if you rotate it to the left, you still end up with a black side on the right; so it looks like it may work only for the upcoming iOS 8. Also, when I add the classes to my project, Xcode throws up warnings over UIVisualEffects, which again may be iOS 8 specific.

Black tint

Awesome custom segue! Is there a way to make a this segue have a black tint? Right now I'm changing the tint color but it doesn't affect anything. It just looks like a blurred window (clear).

Realizing this may be an issue for iOS 8 where you can't customize segs

Weird shadow after segue (iOS 8)

weirdshadow

After performing a blur segue, on the right hand side I'm getting a shadow effect running from top to bottom and I can't figure out what's causing it. Any ideas? Thanks!

setUseDefaultModalPresentationStyle - unrecognized selector sent to instance

Hey there, the library works perfectly on iOS8+. However on iOS 7, I keep getting this error:

2015-10-08 11:27:50.762 APPNAME[3104:60b] -[AFBlurSegue setUseDefaultModalPresentationStyle:]: unrecognized selector sent to instance 0x17dc01b0
2015-10-08 11:27:50.771 APPNAME[3104:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AFBlurSegue setUseDefaultModalPresentationStyle:]: unrecognized selector sent to instance 0x17dc01b0'
*** First throw call stack:
(0x2f0f4f83 0x398a5ccf 0x2f0f8917 0x2f0f7203 0x2f046768 0x31dee381 0x31de43fb 0x31a3000f 0x31ae2357 0x319916d5 0x3190a53b 0x2f0c0255 0x2f0bdbf9 0x2f0bdf3b 0x2f028ebf 0x2f028ca3 0x33f2e663 0x3197514d 0xaae38 0x39db2ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

I can't seem to find this method in the library, so do you know what's causing the problem?

Edit: StackOverflow question

Not working on iOS 9.2.1

When applying the transition, the blur effect is not showing, the destination view shows an gray/dark opaque background totally covering the presenting view controller. Any ideas? Thanks.

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.