Skip to content

Commit

Permalink
Add CocoaPods for blurring library, implement blurring segue
Browse files Browse the repository at this point in the history
  • Loading branch information
mhupman committed Nov 21, 2013
1 parent 7f19d4e commit 1976fab
Show file tree
Hide file tree
Showing 8 changed files with 1,267 additions and 535 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OS X
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.xccheckout

# CocoaPods
Pods
1,656 changes: 1,161 additions & 495 deletions BlurryModal.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions BlurryModal.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 27 additions & 35 deletions BlurryModal/Base.lproj/Main_iPhone.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="uQO-Pf-Bss">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<scenes>
<!--View Controller-->
<!--View Controller - Dingle-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
Expand Down Expand Up @@ -38,7 +38,7 @@ sdjflasdjf sdf asdf asdf</string>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="gmy-4C-a11" kind="modal" id="WLR-co-kfa"/>
<segue destination="fNc-wg-8eJ" kind="modal" id="IDn-ZG-rky"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2Ne-QE-003">
Expand All @@ -54,40 +54,11 @@ sdjflasdjf sdf asdf asdf</string>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" title="Dingle" id="XMq-m9-IiL"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
</scene>
<!--View Controller-->
<scene sceneID="0tv-re-Fl7">
<objects>
<viewController id="gmy-4C-a11" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Wxm-eT-nuN"/>
<viewControllerLayoutGuide type="bottom" id="Iek-vv-1F0"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="RRf-2b-6cd">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1RT-4V-VOq">
<rect key="frame" x="137" y="258" width="46" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="Cuj-EB-Wew" kind="unwind" unwindAction="unwindToThisViewController:" id="1Jy-Is-47h"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="MXw-GX-3hO" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="Cuj-EB-Wew" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="780" y="594"/>
<point key="canvasLocation" x="859" y="154"/>
</scene>
<!--View Controller-->
<scene sceneID="aqV-av-KX4">
Expand Down Expand Up @@ -118,12 +89,33 @@ sdjflasdjf sdf asdf asdf</string>
<placeholder placeholderIdentifier="IBFirstResponder" id="jkN-xP-Ik2" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="hmA-f6-gsC" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="780" y="-144"/>
<point key="canvasLocation" x="1338" y="154"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="JHf-2z-qtw">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="uQO-Pf-Bss" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="p9K-rA-Z4I">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="rootViewController" id="JXw-3K-VYd"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jk1-Sa-3Ic" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="520" y="822"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
<segue reference="gfC-Xy-P4C"/>
</inferredMetricsTieBreakers>
</document>
6 changes: 6 additions & 0 deletions BlurryModal/BlurryModalSegue.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

#import <UIKit/UIKit.h>

@class BlurryModalSegue;

typedef UIImage*(^ProcessBackgroundImage)(BlurryModalSegue* blurryModalSegue, UIImage* rawImage);

@interface BlurryModalSegue : UIStoryboardSegue

@property (nonatomic, copy) ProcessBackgroundImage processBackgroundImage;

@end
41 changes: 36 additions & 5 deletions BlurryModal/BlurryModalSegue.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,48 @@
//

#import "BlurryModalSegue.h"
#import <QuartzCore/QuartzCore.h>
#import <UIImage+BlurredFrame/UIImage+ImageEffects.h>

@implementation BlurryModalSegue

- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
{
return [super initWithIdentifier:identifier source:source destination:destination];
}

- (void)perform
{
UIViewController* source = (UIViewController*)self.sourceViewController;
UIViewController* destination = (UIViewController*)self.destinationViewController;

CGSize windowSize = source.view.window.bounds.size;

UIGraphicsBeginImageContextWithOptions(windowSize, YES, 2.0);
CGContextRef context = UIGraphicsGetCurrentContext();
[source.view.window.layer renderInContext:context];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

if (self.processBackgroundImage)
{
snapshot = self.processBackgroundImage(self, snapshot);
}
else
{
snapshot = [snapshot applyBlurWithRadius:15 tintColor:nil saturationDeltaFactor:0 maskImage:nil];
}

destination.view.clipsToBounds = YES;

UIImageView* backgroundImageView = [[UIImageView alloc] initWithImage:snapshot];
backgroundImageView.frame = CGRectMake(0, -windowSize.height, windowSize.width, windowSize.height);

[destination.view addSubview:backgroundImageView];
[destination.view sendSubviewToBack:backgroundImageView];

[self.sourceViewController presentModalViewController:self.destinationViewController animated:YES];

[destination.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[UIView animateWithDuration:[context transitionDuration] animations:^{
backgroundImageView.frame = CGRectMake(0, 0, windowSize.width, windowSize.height);
}];
} completion:nil];
}

@end
3 changes: 3 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
platform :ios, '7.0'

pod 'UIImage+BlurredFrame'
10 changes: 10 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PODS:
- UIImage+BlurredFrame (0.0.2)

DEPENDENCIES:
- UIImage+BlurredFrame

SPEC CHECKSUMS:
UIImage+BlurredFrame: e35b3b542923b64e0ef1c5cfd2ef7971a9a0b2a3

COCOAPODS: 0.27.1

0 comments on commit 1976fab

Please sign in to comment.