Code Monkey home page Code Monkey logo

blurrymodalsegue's Introduction

BlurryModalSegue

BlurryModalSegue is a UIStoryboardSegue subclass that provides a blur effect for modal storyboard segues. It provides the look and feel of a transparent modal overlay without deviating from the modal presentation model provided by Apple.

Demo

Installation

Via CocoaPods:

pod 'BlurryModalSegue'

Usage

Storyboard Usage

Change your modal storyboard segues from this:

To this:

Done!

If nested view controllers are being presented (e.g., UINavigationController -> UIViewController), make sure to set the background color of any nested views to [UIColor clearColor] so the blurry UIImageView is visible

Custom Styling

BlurryModalSegue conforms to the UIAppearance protocol. Configure it once across the app:

#import "BlurryModalSegue.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[BlurryModalSegue appearance] setBackingImageBlurRadius:@(20)];
    [[BlurryModalSegue appearance] setBackingImageSaturationDeltaFactor:@(.45)];
    
    return YES;
}

Additionally, you can customize individual instances before presentation, just implement prepareForSegue:sender::

#import "BlurryModalSegue.h"

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue isKindOfClass:[BlurryModalSegue class]])
    {
        BlurryModalSegue* bms = (BlurryModalSegue*)segue;
        
        bms.backingImageBlurRadius = @(20);
        bms.backingImageSaturationDeltaFactor = @(.45);
        bms.backingImageTintColor = [[UIColor greenColor] colorWithAlphaComponent:.1];
    }
}

Troubleshooting

If you just see a solid color instead of a blurry background after performing a segue, ensure that the view controllers being presented don't have a background color set on their views. This is common when presenting a UINavigationController that is in turn presenting a root view controller. The UIImageView that contains the blurry image is added as a subview to the -[UIStorybardSegue destinationViewController]'s view property. In the case of a presented UINavigationController, it immediately presents a child view controller. If that view controller has a solid background color, it could completely hide the blurry UIImageView.

Compatibility/Restrictions

  • iOS7+ only, as we take advantage of the new UIViewControllerTransitionCoordinator.
  • UIModalTransitionStylePartialCurl is not supported and doesn't really make sense for this library.
  • For UIModalTransitionStyleCoverVertical, eagle-eyed developers will notice that the effect is better during presentation than dismissal. This is because [UIViewController -transitionCoordinator] only seems to support the presentation, not the dismissal. I believe the dismissal could be implented using the [UIViewController -transitioningDelegate], but that is TBD.
  • Rotation after modal presentation is unsupported as the backing image will only be appropriate for the original orientation.

Acknowledgements

blurrymodalsegue's People

Contributors

mhupman avatar readmecritic 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blurrymodalsegue's Issues

Blur is black if over another blur.

When the blur modal opens above a UITabbar, sometime (not always!) the modal area right above the tabbar gets a blurred black effect.

I tested with some other blurry views, and this seems to happen most of the time when the blur effect is above another blur.

Broken in iOS 11

BlurryModalSegue seems to be broken in iOS 11. Will circle back later to see if it can be fixed, but if you can update, that would be great. Thanks!

Compiler warning with iOS 7

... /Pods/RNBlurModalView/RNBlurModalView.m:413:38: 'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

... /Pods/RNBlurModalView/RNBlurModalView.m:689:46: Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGBitmapInfo' (aka 'enum CGBitmapInfo')

Issue with segue to second view controller

Segueing to a view controller embedded inside of a UINavigationController works great, but then a push segue to another controller causes a hang during the animation.

animation

App crashing on segue

Using coacoapods, dependencies were installed correctly but still getting:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a segue class named 'BlurryModalSegue''

The blurred background is rotating

Take a look at the screen shots, the blurred background is being rotated.

img_0307

img_0308

The code:

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

    if ([segue.identifier isEqualToString:@"segueExibirEstabelecimento"]) {

        EstabelecimentoViewController *estabelecimentoViewController = segue.destinationViewController;

        [estabelecimentoViewController setEstabelecimento:sender];
        [estabelecimentoViewController setDelegateFechar:self];

        BlurryModalSegue* bms = (BlurryModalSegue*)segue;

        bms.backingImageBlurRadius = @(5);
        //bms.backingImageSaturationDeltaFactor = @(.45);

    }

}

Limited rotation support

I understand that you can't change the blurred image if there is rotation. However it would be much more usable if I could choose a background color behind the image and center justification.

Question: dismiss with custom transition

Hi,
I am presenting a blurry modal segue from a controller which conforms to UIViewControllerTransitioningDelegate. The presentation animation works as expected but when invoking the unwind to dismiss the modal the dismiss animation is never invoked and the modal is not dismissed at all.

Thanks

Getting error ‘Could not find a segue class named ‘BlurryModalSegue''

pod was installed without any errors and worked perfectly on a separate project built a couple weeks back using the exact same method.

After changing the default modal segue with custom and applying 'BlurryModalSegue', following error is shown on the console even when Segue class shows 'BlurryModalSegue' as an option in the dropdown:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a segue class named 'BlurryModalSegue''

Line at bottom of Modal Segue

When presenting the modal view on iOS 8 there is a blinking line at the bottom of the modal.

img_0149
Its hard to see here but there is a white line on the bottom of the image.

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.