mtonio91 / AMSmoothAlert

Cool AlertView
MIT License
1.26k stars 158 forks source link

Alternative without GPUImage Framework #22

Open HeyChristian opened 10 years ago

HeyChristian commented 10 years ago

This is an alternative to NOT using GPUImage Framework, this function can capture a screenshot and place the blur effect.

I added a "AMSmoothAlertView.m" this function to return the image with the effect.

#import "UIImage+ImageEffects.h"

-(UIImage *)blurredSnapshot
{
    // Create the image context
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.window.screen.scale);

    // There he is! The new API method
    [self drawViewHierarchyInRect:self.frame afterScreenUpdates:NO];

    // Get the snapshot
    UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();

    // Now apply the blur effect using Apple's UIImageEffect category
    UIImage *blurredSnapshotImage = [snapshotImage applyDarkEffect];
    //applyLightEffect
    // Or apply any other effects available in "UIImage+ImageEffects.h"
    // UIImage *blurredSnapshotImage = [snapshotImage applyDarkEffect];
    // UIImage *blurredSnapshotImage = [snapshotImage applyExtraLightEffect];

    // Be nice and clean your mess up
    UIGraphicsEndImageContext();

    return blurredSnapshotImage;
}
HeyChristian commented 10 years ago

http://damir.me/ios7-blurring-techniques

mtonio91 commented 10 years ago

i'll try it and integrate it if it works great ! (interested about performances, could be a solution) thank you for contributing !

mtonio91 commented 10 years ago

It appears it's not a blur effect but a dark effect.

HeyChristian commented 10 years ago

has several highlights in the background, does not look bad with your alerviews ios simulator screen shot may 30 2014 3 09 05 am

nvnguyenit commented 10 years ago

Thanks so much! You save my time!

franciscomxs commented 10 years ago

:+1

daviddelmonte commented 10 years ago

Thanks a ton for this.. Much faster