├── .gitignore
├── LICENSE
├── README.md
├── RNBlurModalExample.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── hsin41.xcuserdatad
│ └── xcschemes
│ ├── RNBlurModalExample.xcscheme
│ └── xcschememanagement.plist
├── RNBlurModalExample
├── Default-568h@2x.png
├── Default.png
├── Default@2x.png
├── Profile.png
├── Profile@2x.png
├── RNAppDelegate.h
├── RNAppDelegate.m
├── RNBlurModalExample-Info.plist
├── RNBlurModalExample-Prefix.pch
├── RNViewController.h
├── RNViewController.m
├── en.lproj
│ ├── InfoPlist.strings
│ ├── MainStoryboard.storyboard
│ └── MainStoryboard_ipad.storyboard
└── main.m
├── RNBlurModalView.h
├── RNBlurModalView.m
├── RNBlurModalView.podspec
└── images
└── image.jpg
/.gitignore:
--------------------------------------------------------------------------------
1 | # Exclude temp nibs and swap files
2 | *~.nib
3 | *.swp
4 |
5 | # Exclude OS X folder attributes
6 | .DS_Store
7 |
8 | # Exclude user-specific XCode 3 and 4 files
9 | *.mode1
10 | *.mode1v3
11 | *.mode2v3
12 | *.perspective
13 | *.perspectivev3
14 | *.pbxuser
15 | *.xcworkspace
16 | xcuserdata
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Ryan Nystrom (http://whoisryannystrom.com)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | RNBlurModalView
2 | ====
3 |
4 | RNBlurModal adds *depth* to the traditional modal/alert view. Calling the view is incredibly similar to setting up and showing a UIAlertView. You can also setup your own custom views and display them with a blurry background. The goal is to truly draw the user's focus directly to your alert using natural effects. This project works on all iOS devices at all orientations with ARC.
5 |
6 |
7 |
8 | ## Installation
9 |
10 | ### With CocoaPods
11 | Just add this line to your podfile
12 |
13 | ```
14 | pod 'RNBlurModalView', '~> 0.1.0'
15 | ```
16 |
17 | ### Manual installation
18 |
19 | Super simple. Just drag & drop RNBlurModalView.h/.m into your project. In your Project, find the Build Phases tab and expand Link Binary With Libraries. Add the following frameworks to your project:
20 |
21 | * QuartzCore.framework
22 | * Accelerate.framework
23 |
24 | Additionally in your project, under the Build Phases tab, expand Compile Sources and add RNBlurModalView.m.
25 |
26 | ## Usage
27 |
28 | The simplest way to get up and running with RNBlurModalView is to display a default view. Inside of your view controller, write the following code:
29 |
30 | ``` objective-c
31 | RNBlurModalView *modal = [[RNBlurModalView alloc] initWithViewController:self title:@"Hello world!" message:@"Pur your message here."];
32 | [modal show];
33 | ```
34 |
35 | You can also create a modal view with your own custom UIViews:
36 |
37 | ``` objective-c
38 | RNBlurModalView *modal = [[RNBlurModalView alloc] initWithViewController:self view:view];
39 | [modal show];
40 | ```
41 |
42 | ## Caveat
43 |
44 | The only thing I'll warn users about is that animations beneath the modal will be "paused". When it comes down to it, I am overlaying a UIImage on top of your controller. I've tried messing with some hacky CADisplayLink
methods, but I can't seem to get a screenshot of the present *state* of the controller, just the configuration.
45 |
46 | ## Configuration
47 |
48 | Set a couple of different properties of your modal view to change how it appears:
49 |
50 | ``` objective-c
51 | @property (assign) CGFloat animationDuration;
52 | @property (assign) CGFloat animationDelay;
53 | @property (assign) UIViewAnimationOptions animationOptions;
54 | ```
55 |
56 | For brevity, you can instead set these properties in the show:
and hide:
methods.
57 |
58 | ``` objective-c
59 | // show
60 | - (void)show;
61 | - (void)showWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion;
62 | // hide
63 | - (void)hide;
64 | - (void)hideWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion;
65 | ```
66 |
67 | ## KVO & Notifications
68 |
69 | As always, I try to include some helpers in case there are other objects that need to be notified of custom events.
70 |
71 | ##### NSNotifications
72 |
73 | ``` objective-c
74 | extern NSString * const kRNBlurDidShowNotification;
75 | extern NSString * const kRNBlurDidHidewNotification;
76 | ```
77 |
78 | ##### KVO
79 |
80 | ``` objective-c
81 | @property (assign, readonly) BOOL isVisible;
82 | ```
83 |
84 | ## Contributions
85 |
86 | The drawing for the dismiss button comes from [David Keegan's](http://davidkeegan.com/) awesome [KGModal](https://github.com/kgn/KGModal) project.
87 |
88 | The blurring algorithm is applied from this [awesome blog post](http://indieambitions.com/idevblogaday/perform-blur-vimage-accelerate-framework-tutorial/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+IndieAmbitions+%28Indie+Ambitions%29).
89 |
90 | ## Contact
91 |
92 | * [@nystrorm](https://twitter.com/nystrorm) on Twitter
93 | * [@rnystrom](https://github.com/rnystrom) on Github
94 | * rnystrom [at] whoisryannystrom [dot] com
95 |
96 | ## License
97 |
98 | Copyright (c) 2012 Ryan Nystrom (http://whoisryannystrom.com)
99 |
100 | Permission is hereby granted, free of charge, to any person obtaining a copy
101 | of this software and associated documentation files (the "Software"), to deal
102 | in the Software without restriction, including without limitation the rights
103 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
104 | copies of the Software, and to permit persons to whom the Software is
105 | furnished to do so, subject to the following conditions:
106 |
107 | The above copyright notice and this permission notice shall be included in
108 | all copies or substantial portions of the Software.
109 |
110 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
111 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
112 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
113 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
114 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
115 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
116 | THE SOFTWARE.
--------------------------------------------------------------------------------
/RNBlurModalExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 3C5B27C2930419E66B84C9C0 /* RNBlurModalView.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 3C5B23C833DA9944184E2F7E /* RNBlurModalView.podspec */; };
11 | 866E0B40162F2F2D00DE51B9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 866E0B3F162F2F2D00DE51B9 /* UIKit.framework */; };
12 | 866E0B42162F2F2D00DE51B9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 866E0B41162F2F2D00DE51B9 /* Foundation.framework */; };
13 | 866E0B44162F2F2D00DE51B9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 866E0B43162F2F2D00DE51B9 /* CoreGraphics.framework */; };
14 | 866E0B4A162F2F2D00DE51B9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B48162F2F2D00DE51B9 /* InfoPlist.strings */; };
15 | 866E0B4C162F2F2D00DE51B9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 866E0B4B162F2F2D00DE51B9 /* main.m */; };
16 | 866E0B50162F2F2D00DE51B9 /* RNAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 866E0B4F162F2F2D00DE51B9 /* RNAppDelegate.m */; };
17 | 866E0B52162F2F2D00DE51B9 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B51162F2F2D00DE51B9 /* Default.png */; };
18 | 866E0B54162F2F2D00DE51B9 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B53162F2F2D00DE51B9 /* Default@2x.png */; };
19 | 866E0B56162F2F2D00DE51B9 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B55162F2F2D00DE51B9 /* Default-568h@2x.png */; };
20 | 866E0B59162F2F2D00DE51B9 /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B57162F2F2D00DE51B9 /* MainStoryboard.storyboard */; };
21 | 866E0B5C162F2F2D00DE51B9 /* RNViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 866E0B5B162F2F2D00DE51B9 /* RNViewController.m */; };
22 | 866E0B64162F30AF00DE51B9 /* Profile.png in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B62162F30AF00DE51B9 /* Profile.png */; };
23 | 866E0B65162F30AF00DE51B9 /* Profile@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 866E0B63162F30AF00DE51B9 /* Profile@2x.png */; };
24 | 866E0B68162F31BE00DE51B9 /* RNBlurModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 866E0B67162F31BE00DE51B9 /* RNBlurModalView.m */; };
25 | 866E0B6A162F323300DE51B9 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 866E0B69162F323300DE51B9 /* QuartzCore.framework */; };
26 | 866E0B75162F44D400DE51B9 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 866E0B74162F44D400DE51B9 /* Accelerate.framework */; };
27 | 867FFEB31631E18500EE9936 /* MainStoryboard_ipad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 867FFEB11631E18500EE9936 /* MainStoryboard_ipad.storyboard */; };
28 | 86A650D9163080D5001DD552 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86A650D8163080D5001DD552 /* CoreImage.framework */; };
29 | /* End PBXBuildFile section */
30 |
31 | /* Begin PBXFileReference section */
32 | 3C5B23C833DA9944184E2F7E /* RNBlurModalView.podspec */ = {isa = PBXFileReference; lastKnownFileType = file.podspec; path = RNBlurModalView.podspec; sourceTree = ""; };
33 | 866E0B3B162F2F2D00DE51B9 /* RNBlurModalExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNBlurModalExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 866E0B3F162F2F2D00DE51B9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
35 | 866E0B41162F2F2D00DE51B9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
36 | 866E0B43162F2F2D00DE51B9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
37 | 866E0B47162F2F2D00DE51B9 /* RNBlurModalExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "RNBlurModalExample-Info.plist"; sourceTree = ""; };
38 | 866E0B49162F2F2D00DE51B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
39 | 866E0B4B162F2F2D00DE51B9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
40 | 866E0B4D162F2F2D00DE51B9 /* RNBlurModalExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNBlurModalExample-Prefix.pch"; sourceTree = ""; };
41 | 866E0B4E162F2F2D00DE51B9 /* RNAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNAppDelegate.h; sourceTree = ""; };
42 | 866E0B4F162F2F2D00DE51B9 /* RNAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNAppDelegate.m; sourceTree = ""; };
43 | 866E0B51162F2F2D00DE51B9 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; };
44 | 866E0B53162F2F2D00DE51B9 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; };
45 | 866E0B55162F2F2D00DE51B9 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; };
46 | 866E0B58162F2F2D00DE51B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard.storyboard; sourceTree = ""; };
47 | 866E0B5A162F2F2D00DE51B9 /* RNViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNViewController.h; sourceTree = ""; };
48 | 866E0B5B162F2F2D00DE51B9 /* RNViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNViewController.m; sourceTree = ""; };
49 | 866E0B62162F30AF00DE51B9 /* Profile.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Profile.png; sourceTree = ""; };
50 | 866E0B63162F30AF00DE51B9 /* Profile@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Profile@2x.png"; sourceTree = ""; };
51 | 866E0B66162F31BE00DE51B9 /* RNBlurModalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNBlurModalView.h; sourceTree = SOURCE_ROOT; };
52 | 866E0B67162F31BE00DE51B9 /* RNBlurModalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNBlurModalView.m; sourceTree = SOURCE_ROOT; };
53 | 866E0B69162F323300DE51B9 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
54 | 866E0B74162F44D400DE51B9 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
55 | 867FFEB21631E18500EE9936 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_ipad.storyboard; sourceTree = ""; };
56 | 86A650D8163080D5001DD552 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; };
57 | /* End PBXFileReference section */
58 |
59 | /* Begin PBXFrameworksBuildPhase section */
60 | 866E0B38162F2F2D00DE51B9 /* Frameworks */ = {
61 | isa = PBXFrameworksBuildPhase;
62 | buildActionMask = 2147483647;
63 | files = (
64 | 86A650D9163080D5001DD552 /* CoreImage.framework in Frameworks */,
65 | 866E0B75162F44D400DE51B9 /* Accelerate.framework in Frameworks */,
66 | 866E0B6A162F323300DE51B9 /* QuartzCore.framework in Frameworks */,
67 | 866E0B40162F2F2D00DE51B9 /* UIKit.framework in Frameworks */,
68 | 866E0B42162F2F2D00DE51B9 /* Foundation.framework in Frameworks */,
69 | 866E0B44162F2F2D00DE51B9 /* CoreGraphics.framework in Frameworks */,
70 | );
71 | runOnlyForDeploymentPostprocessing = 0;
72 | };
73 | /* End PBXFrameworksBuildPhase section */
74 |
75 | /* Begin PBXGroup section */
76 | 866E0B30162F2F2D00DE51B9 = {
77 | isa = PBXGroup;
78 | children = (
79 | 866E0B66162F31BE00DE51B9 /* RNBlurModalView.h */,
80 | 866E0B67162F31BE00DE51B9 /* RNBlurModalView.m */,
81 | 866E0B45162F2F2D00DE51B9 /* RNBlurModalExample */,
82 | 866E0B3E162F2F2D00DE51B9 /* Frameworks */,
83 | 866E0B3C162F2F2D00DE51B9 /* Products */,
84 | 3C5B23C833DA9944184E2F7E /* RNBlurModalView.podspec */,
85 | );
86 | sourceTree = "";
87 | };
88 | 866E0B3C162F2F2D00DE51B9 /* Products */ = {
89 | isa = PBXGroup;
90 | children = (
91 | 866E0B3B162F2F2D00DE51B9 /* RNBlurModalExample.app */,
92 | );
93 | name = Products;
94 | sourceTree = "";
95 | };
96 | 866E0B3E162F2F2D00DE51B9 /* Frameworks */ = {
97 | isa = PBXGroup;
98 | children = (
99 | 86A650D8163080D5001DD552 /* CoreImage.framework */,
100 | 866E0B74162F44D400DE51B9 /* Accelerate.framework */,
101 | 866E0B69162F323300DE51B9 /* QuartzCore.framework */,
102 | 866E0B3F162F2F2D00DE51B9 /* UIKit.framework */,
103 | 866E0B41162F2F2D00DE51B9 /* Foundation.framework */,
104 | 866E0B43162F2F2D00DE51B9 /* CoreGraphics.framework */,
105 | );
106 | name = Frameworks;
107 | sourceTree = "";
108 | };
109 | 866E0B45162F2F2D00DE51B9 /* RNBlurModalExample */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 867FFEB11631E18500EE9936 /* MainStoryboard_ipad.storyboard */,
113 | 866E0B62162F30AF00DE51B9 /* Profile.png */,
114 | 866E0B63162F30AF00DE51B9 /* Profile@2x.png */,
115 | 866E0B4E162F2F2D00DE51B9 /* RNAppDelegate.h */,
116 | 866E0B4F162F2F2D00DE51B9 /* RNAppDelegate.m */,
117 | 866E0B57162F2F2D00DE51B9 /* MainStoryboard.storyboard */,
118 | 866E0B5A162F2F2D00DE51B9 /* RNViewController.h */,
119 | 866E0B5B162F2F2D00DE51B9 /* RNViewController.m */,
120 | 866E0B46162F2F2D00DE51B9 /* Supporting Files */,
121 | );
122 | path = RNBlurModalExample;
123 | sourceTree = "";
124 | };
125 | 866E0B46162F2F2D00DE51B9 /* Supporting Files */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 866E0B47162F2F2D00DE51B9 /* RNBlurModalExample-Info.plist */,
129 | 866E0B48162F2F2D00DE51B9 /* InfoPlist.strings */,
130 | 866E0B4B162F2F2D00DE51B9 /* main.m */,
131 | 866E0B4D162F2F2D00DE51B9 /* RNBlurModalExample-Prefix.pch */,
132 | 866E0B51162F2F2D00DE51B9 /* Default.png */,
133 | 866E0B53162F2F2D00DE51B9 /* Default@2x.png */,
134 | 866E0B55162F2F2D00DE51B9 /* Default-568h@2x.png */,
135 | );
136 | name = "Supporting Files";
137 | sourceTree = "";
138 | };
139 | /* End PBXGroup section */
140 |
141 | /* Begin PBXNativeTarget section */
142 | 866E0B3A162F2F2D00DE51B9 /* RNBlurModalExample */ = {
143 | isa = PBXNativeTarget;
144 | buildConfigurationList = 866E0B5F162F2F2D00DE51B9 /* Build configuration list for PBXNativeTarget "RNBlurModalExample" */;
145 | buildPhases = (
146 | 866E0B37162F2F2D00DE51B9 /* Sources */,
147 | 866E0B38162F2F2D00DE51B9 /* Frameworks */,
148 | 866E0B39162F2F2D00DE51B9 /* Resources */,
149 | );
150 | buildRules = (
151 | );
152 | dependencies = (
153 | );
154 | name = RNBlurModalExample;
155 | productName = RNBlurModalExample;
156 | productReference = 866E0B3B162F2F2D00DE51B9 /* RNBlurModalExample.app */;
157 | productType = "com.apple.product-type.application";
158 | };
159 | /* End PBXNativeTarget section */
160 |
161 | /* Begin PBXProject section */
162 | 866E0B32162F2F2D00DE51B9 /* Project object */ = {
163 | isa = PBXProject;
164 | attributes = {
165 | CLASSPREFIX = RN;
166 | LastUpgradeCheck = 0450;
167 | ORGANIZATIONNAME = "Ryan Nystrom";
168 | };
169 | buildConfigurationList = 866E0B35162F2F2D00DE51B9 /* Build configuration list for PBXProject "RNBlurModalExample" */;
170 | compatibilityVersion = "Xcode 3.2";
171 | developmentRegion = English;
172 | hasScannedForEncodings = 0;
173 | knownRegions = (
174 | en,
175 | );
176 | mainGroup = 866E0B30162F2F2D00DE51B9;
177 | productRefGroup = 866E0B3C162F2F2D00DE51B9 /* Products */;
178 | projectDirPath = "";
179 | projectRoot = "";
180 | targets = (
181 | 866E0B3A162F2F2D00DE51B9 /* RNBlurModalExample */,
182 | );
183 | };
184 | /* End PBXProject section */
185 |
186 | /* Begin PBXResourcesBuildPhase section */
187 | 866E0B39162F2F2D00DE51B9 /* Resources */ = {
188 | isa = PBXResourcesBuildPhase;
189 | buildActionMask = 2147483647;
190 | files = (
191 | 866E0B4A162F2F2D00DE51B9 /* InfoPlist.strings in Resources */,
192 | 866E0B52162F2F2D00DE51B9 /* Default.png in Resources */,
193 | 866E0B54162F2F2D00DE51B9 /* Default@2x.png in Resources */,
194 | 866E0B56162F2F2D00DE51B9 /* Default-568h@2x.png in Resources */,
195 | 866E0B59162F2F2D00DE51B9 /* MainStoryboard.storyboard in Resources */,
196 | 866E0B64162F30AF00DE51B9 /* Profile.png in Resources */,
197 | 866E0B65162F30AF00DE51B9 /* Profile@2x.png in Resources */,
198 | 867FFEB31631E18500EE9936 /* MainStoryboard_ipad.storyboard in Resources */,
199 | 3C5B27C2930419E66B84C9C0 /* RNBlurModalView.podspec in Resources */,
200 | );
201 | runOnlyForDeploymentPostprocessing = 0;
202 | };
203 | /* End PBXResourcesBuildPhase section */
204 |
205 | /* Begin PBXSourcesBuildPhase section */
206 | 866E0B37162F2F2D00DE51B9 /* Sources */ = {
207 | isa = PBXSourcesBuildPhase;
208 | buildActionMask = 2147483647;
209 | files = (
210 | 866E0B4C162F2F2D00DE51B9 /* main.m in Sources */,
211 | 866E0B50162F2F2D00DE51B9 /* RNAppDelegate.m in Sources */,
212 | 866E0B5C162F2F2D00DE51B9 /* RNViewController.m in Sources */,
213 | 866E0B68162F31BE00DE51B9 /* RNBlurModalView.m in Sources */,
214 | );
215 | runOnlyForDeploymentPostprocessing = 0;
216 | };
217 | /* End PBXSourcesBuildPhase section */
218 |
219 | /* Begin PBXVariantGroup section */
220 | 866E0B48162F2F2D00DE51B9 /* InfoPlist.strings */ = {
221 | isa = PBXVariantGroup;
222 | children = (
223 | 866E0B49162F2F2D00DE51B9 /* en */,
224 | );
225 | name = InfoPlist.strings;
226 | sourceTree = "";
227 | };
228 | 866E0B57162F2F2D00DE51B9 /* MainStoryboard.storyboard */ = {
229 | isa = PBXVariantGroup;
230 | children = (
231 | 866E0B58162F2F2D00DE51B9 /* en */,
232 | );
233 | name = MainStoryboard.storyboard;
234 | sourceTree = "";
235 | };
236 | 867FFEB11631E18500EE9936 /* MainStoryboard_ipad.storyboard */ = {
237 | isa = PBXVariantGroup;
238 | children = (
239 | 867FFEB21631E18500EE9936 /* en */,
240 | );
241 | name = MainStoryboard_ipad.storyboard;
242 | sourceTree = "";
243 | };
244 | /* End PBXVariantGroup section */
245 |
246 | /* Begin XCBuildConfiguration section */
247 | 866E0B5D162F2F2D00DE51B9 /* Debug */ = {
248 | isa = XCBuildConfiguration;
249 | buildSettings = {
250 | ALWAYS_SEARCH_USER_PATHS = NO;
251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
252 | CLANG_CXX_LIBRARY = "libc++";
253 | CLANG_ENABLE_OBJC_ARC = YES;
254 | CLANG_WARN_EMPTY_BODY = YES;
255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
256 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
257 | COPY_PHASE_STRIP = NO;
258 | GCC_C_LANGUAGE_STANDARD = gnu99;
259 | GCC_DYNAMIC_NO_PIC = NO;
260 | GCC_OPTIMIZATION_LEVEL = 0;
261 | GCC_PREPROCESSOR_DEFINITIONS = (
262 | "DEBUG=1",
263 | "$(inherited)",
264 | );
265 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
266 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
267 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
268 | GCC_WARN_UNUSED_VARIABLE = YES;
269 | IPHONEOS_DEPLOYMENT_TARGET = 6.0;
270 | ONLY_ACTIVE_ARCH = YES;
271 | SDKROOT = iphoneos;
272 | };
273 | name = Debug;
274 | };
275 | 866E0B5E162F2F2D00DE51B9 /* Release */ = {
276 | isa = XCBuildConfiguration;
277 | buildSettings = {
278 | ALWAYS_SEARCH_USER_PATHS = NO;
279 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
280 | CLANG_CXX_LIBRARY = "libc++";
281 | CLANG_ENABLE_OBJC_ARC = YES;
282 | CLANG_WARN_EMPTY_BODY = YES;
283 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
284 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
285 | COPY_PHASE_STRIP = YES;
286 | GCC_C_LANGUAGE_STANDARD = gnu99;
287 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
288 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
289 | GCC_WARN_UNUSED_VARIABLE = YES;
290 | IPHONEOS_DEPLOYMENT_TARGET = 6.0;
291 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
292 | SDKROOT = iphoneos;
293 | VALIDATE_PRODUCT = YES;
294 | };
295 | name = Release;
296 | };
297 | 866E0B60162F2F2D00DE51B9 /* Debug */ = {
298 | isa = XCBuildConfiguration;
299 | buildSettings = {
300 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
301 | GCC_PREFIX_HEADER = "RNBlurModalExample/RNBlurModalExample-Prefix.pch";
302 | INFOPLIST_FILE = "RNBlurModalExample/RNBlurModalExample-Info.plist";
303 | IPHONEOS_DEPLOYMENT_TARGET = 6.0;
304 | PRODUCT_NAME = "$(TARGET_NAME)";
305 | TARGETED_DEVICE_FAMILY = "1,2";
306 | WRAPPER_EXTENSION = app;
307 | };
308 | name = Debug;
309 | };
310 | 866E0B61162F2F2D00DE51B9 /* Release */ = {
311 | isa = XCBuildConfiguration;
312 | buildSettings = {
313 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
314 | GCC_PREFIX_HEADER = "RNBlurModalExample/RNBlurModalExample-Prefix.pch";
315 | INFOPLIST_FILE = "RNBlurModalExample/RNBlurModalExample-Info.plist";
316 | IPHONEOS_DEPLOYMENT_TARGET = 6.0;
317 | PRODUCT_NAME = "$(TARGET_NAME)";
318 | TARGETED_DEVICE_FAMILY = "1,2";
319 | WRAPPER_EXTENSION = app;
320 | };
321 | name = Release;
322 | };
323 | /* End XCBuildConfiguration section */
324 |
325 | /* Begin XCConfigurationList section */
326 | 866E0B35162F2F2D00DE51B9 /* Build configuration list for PBXProject "RNBlurModalExample" */ = {
327 | isa = XCConfigurationList;
328 | buildConfigurations = (
329 | 866E0B5D162F2F2D00DE51B9 /* Debug */,
330 | 866E0B5E162F2F2D00DE51B9 /* Release */,
331 | );
332 | defaultConfigurationIsVisible = 0;
333 | defaultConfigurationName = Release;
334 | };
335 | 866E0B5F162F2F2D00DE51B9 /* Build configuration list for PBXNativeTarget "RNBlurModalExample" */ = {
336 | isa = XCConfigurationList;
337 | buildConfigurations = (
338 | 866E0B60162F2F2D00DE51B9 /* Debug */,
339 | 866E0B61162F2F2D00DE51B9 /* Release */,
340 | );
341 | defaultConfigurationIsVisible = 0;
342 | defaultConfigurationName = Release;
343 | };
344 | /* End XCConfigurationList section */
345 | };
346 | rootObject = 866E0B32162F2F2D00DE51B9 /* Project object */;
347 | }
348 |
--------------------------------------------------------------------------------
/RNBlurModalExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/RNBlurModalExample.xcodeproj/xcuserdata/hsin41.xcuserdatad/xcschemes/RNBlurModalExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/RNBlurModalExample.xcodeproj/xcuserdata/hsin41.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | RNBlurModalExample.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 866E0B3A162F2F2D00DE51B9
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/RNBlurModalExample/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rnystrom/RNBlurModalView/ddbdd9e43be24e6f43e69e41f9c8f5394e5cdf5e/RNBlurModalExample/Default-568h@2x.png
--------------------------------------------------------------------------------
/RNBlurModalExample/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rnystrom/RNBlurModalView/ddbdd9e43be24e6f43e69e41f9c8f5394e5cdf5e/RNBlurModalExample/Default.png
--------------------------------------------------------------------------------
/RNBlurModalExample/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rnystrom/RNBlurModalView/ddbdd9e43be24e6f43e69e41f9c8f5394e5cdf5e/RNBlurModalExample/Default@2x.png
--------------------------------------------------------------------------------
/RNBlurModalExample/Profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rnystrom/RNBlurModalView/ddbdd9e43be24e6f43e69e41f9c8f5394e5cdf5e/RNBlurModalExample/Profile.png
--------------------------------------------------------------------------------
/RNBlurModalExample/Profile@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rnystrom/RNBlurModalView/ddbdd9e43be24e6f43e69e41f9c8f5394e5cdf5e/RNBlurModalExample/Profile@2x.png
--------------------------------------------------------------------------------
/RNBlurModalExample/RNAppDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * RNBlurModal
3 | *
4 | * Created by Ryan Nystrom on 10/2/12.
5 | * Copyright (c) 2012 Ryan Nystrom. All rights reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 |
26 | #import
27 |
28 | @interface RNAppDelegate : UIResponder
29 |
30 | @property (strong, nonatomic) UIWindow *window;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/RNBlurModalExample/RNAppDelegate.m:
--------------------------------------------------------------------------------
1 | /*
2 | * RNBlurModal
3 | *
4 | * Created by Ryan Nystrom on 10/2/12.
5 | * Copyright (c) 2012 Ryan Nystrom. All rights reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 |
26 | #import "RNAppDelegate.h"
27 |
28 | @implementation RNAppDelegate
29 |
30 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
31 | {
32 | // Override point for customization after application launch.
33 | return YES;
34 | }
35 |
36 | - (void)applicationWillResignActive:(UIApplication *)application
37 | {
38 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
39 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
40 | }
41 |
42 | - (void)applicationDidEnterBackground:(UIApplication *)application
43 | {
44 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
45 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
46 | }
47 |
48 | - (void)applicationWillEnterForeground:(UIApplication *)application
49 | {
50 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
51 | }
52 |
53 | - (void)applicationDidBecomeActive:(UIApplication *)application
54 | {
55 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
56 | }
57 |
58 | - (void)applicationWillTerminate:(UIApplication *)application
59 | {
60 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
61 | }
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/RNBlurModalExample/RNBlurModalExample-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | Ryan-Nystrom.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIMainStoryboardFile
28 | MainStoryboard
29 | UIMainStoryboardFile~ipad
30 | MainStoryboard_ipad
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | UISupportedInterfaceOrientations~ipad
42 |
43 | UIInterfaceOrientationPortrait
44 | UIInterfaceOrientationLandscapeLeft
45 | UIInterfaceOrientationLandscapeRight
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/RNBlurModalExample/RNBlurModalExample-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'RNBlurModalExample' target in the 'RNBlurModalExample' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_5_0
8 | #warning "This project uses features only available in iOS SDK 5.0 and later."
9 | #endif
10 |
11 | #ifdef __OBJC__
12 | #import
13 | #import
14 | #endif
15 |
--------------------------------------------------------------------------------
/RNBlurModalExample/RNViewController.h:
--------------------------------------------------------------------------------
1 | /*
2 | * RNBlurModal
3 | *
4 | * Created by Ryan Nystrom on 10/2/12.
5 | * Copyright (c) 2012 Ryan Nystrom. All rights reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 |
26 | #import
27 |
28 | @interface RNViewController : UIViewController
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/RNBlurModalExample/RNViewController.m:
--------------------------------------------------------------------------------
1 | /*
2 | * RNBlurModal
3 | *
4 | * Created by Ryan Nystrom on 10/2/12.
5 | * Copyright (c) 2012 Ryan Nystrom. All rights reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 |
26 | #import "RNViewController.h"
27 | #import "RNBlurModalView.h"
28 | #import
29 |
30 | @interface RNViewController ()
31 | @property (weak, nonatomic) IBOutlet UIImageView *imageView;
32 |
33 | @end
34 |
35 | @implementation RNViewController
36 |
37 | - (void)viewDidLoad
38 | {
39 | [super viewDidLoad];
40 | // Do any additional setup after loading the view, typically from a nib.
41 | }
42 |
43 | - (void)didReceiveMemoryWarning
44 | {
45 | [super didReceiveMemoryWarning];
46 | // Dispose of any resources that can be recreated.
47 | }
48 |
49 | - (IBAction)onDemoButton:(id)sender {
50 | #warning Change this to see a custom view
51 | BOOL useCustomView = NO;
52 |
53 | RNBlurModalView *modal;
54 | if (useCustomView) {
55 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
56 | view.backgroundColor = [UIColor redColor];
57 | view.layer.cornerRadius = 5.f;
58 | view.layer.borderColor = [UIColor blackColor].CGColor;
59 | view.layer.borderWidth = 5.f;
60 |
61 | modal = [[RNBlurModalView alloc] initWithView:view];
62 | }
63 | else {
64 | modal = [[RNBlurModalView alloc] initWithTitle:@"Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world!" message:@"This is the default modal for RNBlurModalView. Feel free to pass any UIView to it as you wish!"];
65 | modal.defaultHideBlock = ^{
66 | NSLog(@"Code called after the modal view is hidden");
67 | };
68 | }
69 | // modal.dismissButtonRight = YES;
70 | [modal show];
71 | }
72 |
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/RNBlurModalExample/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/RNBlurModalExample/en.lproj/MainStoryboard.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
42 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/RNBlurModalExample/en.lproj/MainStoryboard_ipad.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
40 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/RNBlurModalExample/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // RNBlurModalExample
4 | //
5 | // Created by Ryan Nystrom on 10/17/12.
6 | // Copyright (c) 2012 Ryan Nystrom. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RNAppDelegate.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([RNAppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/RNBlurModalView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * RNBlurModal
3 | *
4 | * Created by Ryan Nystrom on 10/2/12.
5 | * Copyright (c) 2012 Ryan Nystrom. All rights reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 |
26 | #import
27 | #import
28 |
29 | extern NSString * const kRNBlurDidShowNotification;
30 | extern NSString * const kRNBlurDidHidewNotification;
31 |
32 | @interface RNBlurModalView : UIView
33 |
34 | @property (assign, readonly) BOOL isVisible;
35 |
36 | @property (assign) CGFloat animationDuration;
37 | @property (assign) CGFloat animationDelay;
38 | @property (assign) UIViewAnimationOptions animationOptions;
39 | @property (assign) BOOL dismissButtonRight;
40 | @property (nonatomic, copy) void (^defaultHideBlock)(void);
41 |
42 | - (id)initWithViewController:(UIViewController*)viewController view:(UIView*)view;
43 | - (id)initWithViewController:(UIViewController*)viewController title:(NSString*)title message:(NSString*)message;
44 | - (id)initWithParentView:(UIView*)parentView view:(UIView*)view;
45 | - (id)initWithParentView:(UIView*)parentView title:(NSString*)title message:(NSString*)message;
46 | - (id)initWithView:(UIView*)view;
47 | - (id)initWithTitle:(NSString*)title message:(NSString*)message;
48 |
49 | - (void)show;
50 | - (void)showWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion;
51 |
52 | - (void)hide;
53 | - (void)hideWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion;
54 |
55 | -(void)hideCloseButton:(BOOL)hide;
56 |
57 |
58 | @end
--------------------------------------------------------------------------------
/RNBlurModalView.m:
--------------------------------------------------------------------------------
1 | /*
2 | * RNBlurModal
3 | *
4 | * Created by Ryan Nystrom on 10/2/12.
5 | * Copyright (c) 2012 Ryan Nystrom. All rights reserved.
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | * SOFTWARE.
24 | */
25 |
26 | #import "RNBlurModalView.h"
27 | #import
28 | #import
29 |
30 | /*
31 | This bit is important! In order to prevent capturing selected states of UIResponders I've implemented a delay. Please feel free to set this delay to *whatever* you deem apprpriate.
32 | I've defaulted it to 0.125 seconds. You can do shorter/longer as you see fit.
33 | */
34 | CGFloat const kRNBlurDefaultDelay = 0.125f;
35 |
36 | /*
37 | You can also change this constant to make the blur more "blurry". I recommend the tasteful level of 0.2 and no higher. However, you are free to change this from 0.0 to 1.0.
38 | */
39 | CGFloat const kRNDefaultBlurScale = 0.2f;
40 |
41 | CGFloat const kRNBlurDefaultDuration = 0.2f;
42 | CGFloat const kRNBlurViewMaxAlpha = 1.f;
43 |
44 | CGFloat const kRNBlurBounceOutDurationScale = 0.8f;
45 |
46 | NSString * const kRNBlurDidShowNotification = @"com.whoisryannystrom.RNBlurModalView.show";
47 | NSString * const kRNBlurDidHidewNotification = @"com.whoisryannystrom.RNBlurModalView.hide";
48 |
49 | typedef void (^RNBlurCompletion)(void);
50 |
51 | @interface UILabel (AutoSize)
52 | - (void)autoHeight;
53 | @end
54 |
55 | @interface UIView (Sizes)
56 | @property (nonatomic) CGFloat left;
57 | @property (nonatomic) CGFloat top;
58 | @property (nonatomic) CGFloat right;
59 | @property (nonatomic) CGFloat bottom;
60 | @property (nonatomic) CGFloat width;
61 | @property (nonatomic) CGFloat height;
62 | @property (nonatomic) CGPoint origin;
63 | @property (nonatomic) CGSize size;
64 | @end
65 |
66 | @interface UIView (Screenshot)
67 | - (UIImage*)screenshot;
68 | @end
69 |
70 | @interface UIImage (Blur)
71 | -(UIImage *)boxblurImageWithBlur:(CGFloat)blur;
72 | @end
73 |
74 | @interface RNBlurView : UIImageView
75 | - (id)initWithCoverView:(UIView*)view;
76 | @end
77 |
78 | @interface RNCloseButton : UIButton
79 | @end
80 |
81 | @interface RNBlurModalView ()
82 | @property (assign, readwrite) BOOL isVisible;
83 | @end
84 |
85 | #pragma mark - RNBlurModalView
86 |
87 | @implementation RNBlurModalView {
88 | UIViewController *_controller;
89 | UIView *_parentView;
90 | UIView *_contentView;
91 | RNCloseButton *_dismissButton;
92 | RNBlurView *_blurView;
93 | RNBlurCompletion _completion;
94 | }
95 |
96 | + (UIView*)generateModalViewWithTitle:(NSString*)title message:(NSString*)message {
97 | CGFloat defaultWidth = 280.f;
98 | CGRect frame = CGRectMake(0, 0, defaultWidth, 0);
99 | CGFloat padding = 10.f;
100 | UIView *view = [[UIView alloc] initWithFrame:frame];
101 |
102 | UIColor *whiteColor = [UIColor colorWithRed:0.816 green:0.788 blue:0.788 alpha:1.000];
103 |
104 | view.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.8f];
105 | view.layer.borderColor = whiteColor.CGColor;
106 | view.layer.borderWidth = 2.f;
107 | view.layer.cornerRadius = 10.f;
108 |
109 | UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(padding, 0, defaultWidth - padding * 2.f, 0)];
110 | titleLabel.text = title;
111 | titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:17.f];
112 | titleLabel.textColor = [UIColor whiteColor];
113 | titleLabel.shadowColor = [UIColor blackColor];
114 | titleLabel.shadowOffset = CGSizeMake(0, -1);
115 | titleLabel.textAlignment = NSTextAlignmentCenter;
116 | titleLabel.backgroundColor = [UIColor clearColor];
117 | [titleLabel autoHeight];
118 | titleLabel.numberOfLines = 0;
119 | titleLabel.top = padding;
120 | [view addSubview:titleLabel];
121 |
122 | UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(padding, 0, defaultWidth - padding * 2.f, 0)];
123 | messageLabel.text = message;
124 | messageLabel.numberOfLines = 0;
125 | messageLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:17.f];
126 | messageLabel.textColor = titleLabel.textColor;
127 | messageLabel.shadowOffset = titleLabel.shadowOffset;
128 | messageLabel.shadowColor = titleLabel.shadowColor;
129 | messageLabel.textAlignment = NSTextAlignmentCenter;
130 | messageLabel.backgroundColor = [UIColor clearColor];
131 | [messageLabel autoHeight];
132 | messageLabel.top = titleLabel.bottom + padding;
133 | [view addSubview:messageLabel];
134 |
135 | view.height = messageLabel.bottom + padding;
136 |
137 | view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin;
138 |
139 | return view;
140 | }
141 |
142 |
143 | - (id)initWithFrame:(CGRect)frame {
144 | if (self = [super initWithFrame:frame]) {
145 | _dismissButton = [[RNCloseButton alloc] init];
146 | _dismissButton.center = CGPointZero;
147 | [_dismissButton addTarget:self action:@selector(hide) forControlEvents:UIControlEventTouchUpInside];
148 |
149 | self.alpha = 0.f;
150 | self.backgroundColor = [UIColor clearColor];
151 | // self.backgroundColor = [UIColor redColor];
152 | // self.layer.borderWidth = 2.f;
153 | // self.layer.borderColor = [UIColor blackColor].CGColor;
154 |
155 | self.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
156 | UIViewAutoresizingFlexibleHeight |
157 | UIViewAutoresizingFlexibleLeftMargin |
158 | UIViewAutoresizingFlexibleTopMargin);
159 |
160 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChangeNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
161 | }
162 | return self;
163 | }
164 |
165 |
166 |
167 | - (id)initWithViewController:(UIViewController*)viewController view:(UIView*)view {
168 | if (self = [self initWithFrame:CGRectMake(0, 0, viewController.view.width, viewController.view.height)]) {
169 | [self addSubview:view];
170 | _contentView = view;
171 | _contentView.center = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
172 | _controller = viewController;
173 | _parentView = nil;
174 | _contentView.clipsToBounds = YES;
175 | _contentView.layer.masksToBounds = YES;
176 |
177 | _dismissButton.center = CGPointMake(view.left, view.top);
178 | [self addSubview:_dismissButton];
179 | }
180 | return self;
181 | }
182 |
183 |
184 | - (id)initWithViewController:(UIViewController*)viewController title:(NSString*)title message:(NSString*)message {
185 | UIView *view = [RNBlurModalView generateModalViewWithTitle:title message:message];
186 | if (self = [self initWithViewController:viewController view:view]) {
187 | // nothing to see here
188 | }
189 | return self;
190 | }
191 |
192 | - (id)initWithParentView:(UIView*)parentView view:(UIView*)view {
193 | if (self = [self initWithFrame:CGRectMake(0, 0, parentView.width, parentView.height)]) {
194 | [self addSubview:view];
195 | _contentView = view;
196 | _contentView.center = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
197 | _controller = nil;
198 | _parentView = parentView;
199 | _contentView.clipsToBounds = YES;
200 | _contentView.layer.masksToBounds = YES;
201 |
202 | _dismissButton.center = CGPointMake(view.left, view.top);
203 | [self addSubview:_dismissButton];
204 | }
205 | return self;
206 | }
207 |
208 | - (id)initWithParentView:(UIView*)parentView title:(NSString*)title message:(NSString*)message {
209 | UIView *view = [RNBlurModalView generateModalViewWithTitle:title message:message];
210 | if (self = [self initWithParentView:parentView view:view]) {
211 | // nothing to see here
212 | }
213 | return self;
214 | }
215 |
216 |
217 | - (id)initWithView:(UIView*)view {
218 | if (self = [self initWithParentView:[[UIApplication sharedApplication].delegate window].rootViewController.view view:view]) {
219 | // nothing to see here
220 | }
221 | return self;
222 | }
223 |
224 | - (id)initWithTitle:(NSString*)title message:(NSString*)message {
225 | UIView *view = [RNBlurModalView generateModalViewWithTitle:title message:message];
226 | if (self = [self initWithView:view]) {
227 | // nothing to see here
228 | }
229 | return self;
230 | }
231 |
232 | - (void)layoutSubviews {
233 | [super layoutSubviews];
234 |
235 | CGFloat centerX = self.dismissButtonRight ? _contentView.right : _contentView.left;
236 | _dismissButton.center = CGPointMake(centerX, _contentView.top);
237 | }
238 |
239 | - (void)willMoveToSuperview:(UIView *)newSuperview {
240 | [super willMoveToSuperview:newSuperview];
241 | if (newSuperview) {
242 | self.center = CGPointMake(CGRectGetMidX(newSuperview.frame), CGRectGetMidY(newSuperview.frame));
243 | }
244 | }
245 |
246 |
247 | - (void)orientationDidChangeNotification:(NSNotification*)notification {
248 | if ([self isVisible]) {
249 | [self performSelector:@selector(updateSubviews) withObject:nil afterDelay:0.3f];
250 | }
251 | }
252 |
253 |
254 | - (void)updateSubviews {
255 | self.hidden = YES;
256 |
257 | // get new screenshot after orientation
258 | [_blurView removeFromSuperview]; _blurView = nil;
259 | if (_controller) {
260 | _blurView = [[RNBlurView alloc] initWithCoverView:_controller.view];
261 | _blurView.alpha = 1.f;
262 | [_controller.view insertSubview:_blurView belowSubview:self];
263 |
264 | }
265 | else if(_parentView) {
266 | _blurView = [[RNBlurView alloc] initWithCoverView:_parentView];
267 | _blurView.alpha = 1.f;
268 | [_parentView insertSubview:_blurView belowSubview:self];
269 |
270 | }
271 |
272 |
273 |
274 | self.hidden = NO;
275 |
276 | _contentView.center = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
277 | _dismissButton.center = _contentView.origin;
278 | }
279 |
280 |
281 | - (void)dealloc {
282 | [[NSNotificationCenter defaultCenter] removeObserver:self];
283 | }
284 |
285 |
286 | - (void)show {
287 | [self showWithDuration:kRNBlurDefaultDuration delay:0 options:kNilOptions completion:NULL];
288 | }
289 |
290 |
291 | - (void)showWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion {
292 | self.animationDuration = duration;
293 | self.animationDelay = delay;
294 | self.animationOptions = options;
295 | _completion = [completion copy];
296 |
297 | // delay so we dont get button states
298 | [self performSelector:@selector(delayedShow) withObject:nil afterDelay:kRNBlurDefaultDelay];
299 | }
300 |
301 |
302 | - (void)delayedShow {
303 | if (! self.isVisible) {
304 | if (! self.superview) {
305 | if (_controller) {
306 | self.frame = CGRectMake(0, 0, _controller.view.bounds.size.width, _controller.view.bounds.size.height);
307 | [_controller.view addSubview:self];
308 | }
309 | else if(_parentView) {
310 | self.frame = CGRectMake(0, 0, _parentView.bounds.size.width, _parentView.bounds.size.height);
311 |
312 | [_parentView addSubview:self];
313 | }
314 | self.top = 0;
315 | }
316 |
317 | if (_controller) {
318 | _blurView = [[RNBlurView alloc] initWithCoverView:_controller.view];
319 | _blurView.alpha = 0.f;
320 | self.frame = CGRectMake(0, 0, _controller.view.bounds.size.width, _controller.view.bounds.size.height);
321 |
322 | [_controller.view insertSubview:_blurView belowSubview:self];
323 | }
324 | else if(_parentView) {
325 | _blurView = [[RNBlurView alloc] initWithCoverView:_parentView];
326 | _blurView.alpha = 0.f;
327 | self.frame = CGRectMake(0, 0, _parentView.bounds.size.width, _parentView.bounds.size.height);
328 |
329 | [_parentView insertSubview:_blurView belowSubview:self];
330 | }
331 |
332 | self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.4, 0.4);
333 | [UIView animateWithDuration:self.animationDuration animations:^{
334 | _blurView.alpha = 1.f;
335 | self.alpha = 1.f;
336 | self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.f, 1.f);
337 | } completion:^(BOOL finished) {
338 | if (finished) {
339 | [[NSNotificationCenter defaultCenter] postNotificationName:kRNBlurDidShowNotification object:nil];
340 | self.isVisible = YES;
341 | if (_completion) {
342 | _completion();
343 | }
344 | }
345 | }];
346 |
347 | }
348 |
349 | }
350 |
351 |
352 | - (void)hide {
353 | [self hideWithDuration:kRNBlurDefaultDuration delay:0 options:kNilOptions completion:self.defaultHideBlock];
354 | }
355 |
356 |
357 | - (void)hideWithDuration:(CGFloat)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)(void))completion {
358 | if (self.isVisible) {
359 | [UIView animateWithDuration:duration
360 | delay:delay
361 | options:options
362 | animations:^{
363 | self.alpha = 0.f;
364 | _blurView.alpha = 0.f;
365 | }
366 | completion:^(BOOL finished){
367 | if (finished) {
368 | [_blurView removeFromSuperview];
369 | _blurView = nil;
370 | [self removeFromSuperview];
371 |
372 | [[NSNotificationCenter defaultCenter] postNotificationName:kRNBlurDidHidewNotification object:nil];
373 | self.isVisible = NO;
374 | if (completion) {
375 | completion();
376 | }
377 | }
378 | }];
379 | }
380 | }
381 |
382 | -(void)hideCloseButton:(BOOL)hide {
383 | [_dismissButton setHidden:hide];
384 | }
385 |
386 | @end
387 |
388 | #pragma mark - RNBlurView
389 |
390 | @implementation RNBlurView {
391 | UIView *_coverView;
392 | }
393 |
394 | - (id)initWithCoverView:(UIView *)view {
395 | if (self = [super initWithFrame:CGRectMake(0, 0, view.bounds.size.width, view.bounds.size.height)]) {
396 | _coverView = view;
397 | UIImage *blur = [_coverView screenshot];
398 | self.image = [blur boxblurImageWithBlur:kRNDefaultBlurScale];
399 | }
400 | return self;
401 | }
402 |
403 |
404 | @end
405 |
406 | #pragma mark - UILabel + Autosize
407 |
408 | @implementation UILabel (AutoSize)
409 |
410 | - (void)autoHeight {
411 | CGRect frame = self.frame;
412 | CGSize maxSize = CGSizeMake(frame.size.width, 9999);
413 | CGSize expectedSize = [self.text sizeWithFont:self.font constrainedToSize:maxSize lineBreakMode:self.lineBreakMode];
414 | frame.size.height = expectedSize.height;
415 | [self setFrame:frame];
416 | }
417 |
418 | @end
419 |
420 | #pragma mark - UIView + Sizes
421 |
422 | @implementation UIView (Sizes)
423 |
424 | - (CGFloat)left {
425 | return self.frame.origin.x;
426 | }
427 |
428 | - (void)setLeft:(CGFloat)x {
429 | CGRect frame = self.frame;
430 | frame.origin.x = x;
431 | self.frame = frame;
432 | }
433 |
434 | - (CGFloat)top {
435 | return self.frame.origin.y;
436 | }
437 |
438 | - (void)setTop:(CGFloat)y {
439 | CGRect frame = self.frame;
440 | frame.origin.y = y;
441 | self.frame = frame;
442 | }
443 |
444 | - (CGFloat)right {
445 | return self.frame.origin.x + self.frame.size.width;
446 | }
447 |
448 | - (void)setRight:(CGFloat)right {
449 | CGRect frame = self.frame;
450 | frame.origin.x = right - frame.size.width;
451 | self.frame = frame;
452 | }
453 |
454 | - (CGFloat)bottom {
455 | return self.frame.origin.y + self.frame.size.height;
456 | }
457 |
458 | - (void)setBottom:(CGFloat)bottom {
459 | CGRect frame = self.frame;
460 | frame.origin.y = bottom - frame.size.height;
461 | self.frame = frame;
462 | }
463 |
464 | - (CGFloat)width {
465 | return self.frame.size.width;
466 | }
467 |
468 | - (void)setWidth:(CGFloat)width {
469 | CGRect frame = self.frame;
470 | frame.size.width = width;
471 | self.frame = frame;
472 | }
473 |
474 | - (CGFloat)height {
475 | return self.frame.size.height;
476 | }
477 |
478 | - (void)setHeight:(CGFloat)height {
479 | CGRect frame = self.frame;
480 | frame.size.height = height;
481 | self.frame = frame;
482 | }
483 |
484 | - (CGPoint)origin {
485 | return self.frame.origin;
486 | }
487 |
488 | - (void)setOrigin:(CGPoint)origin {
489 | CGRect frame = self.frame;
490 | frame.origin = origin;
491 | self.frame = frame;
492 | }
493 |
494 | - (CGSize)size {
495 | return self.frame.size;
496 | }
497 |
498 | - (void)setSize:(CGSize)size {
499 | CGRect frame = self.frame;
500 | frame.size = size;
501 | self.frame = frame;
502 | }
503 |
504 | @end
505 |
506 | #pragma mark - RNCloseButton
507 |
508 | @implementation RNCloseButton
509 |
510 | - (id)init{
511 | if(!(self = [super initWithFrame:(CGRect){0, 0, 32, 32}])){
512 | return nil;
513 | }
514 | static UIImage *closeButtonImage;
515 | static dispatch_once_t once;
516 | dispatch_once(&once, ^{
517 | closeButtonImage = [self closeButtonImage];
518 | });
519 | [self setBackgroundImage:closeButtonImage forState:UIControlStateNormal];
520 | self.accessibilityTraits |= UIAccessibilityTraitButton;
521 | self.accessibilityLabel = NSLocalizedString(@"Dismiss Alert", @"Dismiss Alert Close Button");
522 | self.accessibilityHint = NSLocalizedString(@"Dismisses this alert.",@"Dismiss Alert close button hint");
523 | return self;
524 | }
525 |
526 | - (UIImage *)closeButtonImage{
527 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0);
528 |
529 | //// General Declarations
530 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
531 | CGContextRef context = UIGraphicsGetCurrentContext();
532 |
533 | //// Color Declarations
534 | UIColor *topGradient = [UIColor colorWithRed:0.21 green:0.21 blue:0.21 alpha:0.9];
535 | UIColor *bottomGradient = [UIColor colorWithRed:0.03 green:0.03 blue:0.03 alpha:0.9];
536 |
537 | //// Gradient Declarations
538 | NSArray *gradientColors = @[(id)topGradient.CGColor,
539 | (id)bottomGradient.CGColor];
540 | CGFloat gradientLocations[] = {0, 1};
541 | CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)gradientColors, gradientLocations);
542 |
543 | //// Shadow Declarations
544 | CGColorRef shadow = [UIColor blackColor].CGColor;
545 | CGSize shadowOffset = CGSizeMake(0, 1);
546 | CGFloat shadowBlurRadius = 3;
547 | CGColorRef shadow2 = [UIColor blackColor].CGColor;
548 | CGSize shadow2Offset = CGSizeMake(0, 1);
549 | CGFloat shadow2BlurRadius = 0;
550 |
551 |
552 | //// Oval Drawing
553 | UIBezierPath *ovalPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(4, 3, 24, 24)];
554 | CGContextSaveGState(context);
555 | [ovalPath addClip];
556 | CGContextDrawLinearGradient(context, gradient, CGPointMake(16, 3), CGPointMake(16, 27), 0);
557 | CGContextRestoreGState(context);
558 |
559 | CGContextSaveGState(context);
560 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow);
561 | [[UIColor whiteColor] setStroke];
562 | ovalPath.lineWidth = 2;
563 | [ovalPath stroke];
564 | CGContextRestoreGState(context);
565 |
566 |
567 | //// Bezier Drawing
568 | UIBezierPath *bezierPath = [UIBezierPath bezierPath];
569 | [bezierPath moveToPoint:CGPointMake(22.36, 11.46)];
570 | [bezierPath addLineToPoint:CGPointMake(18.83, 15)];
571 | [bezierPath addLineToPoint:CGPointMake(22.36, 18.54)];
572 | [bezierPath addLineToPoint:CGPointMake(19.54, 21.36)];
573 | [bezierPath addLineToPoint:CGPointMake(16, 17.83)];
574 | [bezierPath addLineToPoint:CGPointMake(12.46, 21.36)];
575 | [bezierPath addLineToPoint:CGPointMake(9.64, 18.54)];
576 | [bezierPath addLineToPoint:CGPointMake(13.17, 15)];
577 | [bezierPath addLineToPoint:CGPointMake(9.64, 11.46)];
578 | [bezierPath addLineToPoint:CGPointMake(12.46, 8.64)];
579 | [bezierPath addLineToPoint:CGPointMake(16, 12.17)];
580 | [bezierPath addLineToPoint:CGPointMake(19.54, 8.64)];
581 | [bezierPath addLineToPoint:CGPointMake(22.36, 11.46)];
582 | [bezierPath closePath];
583 | CGContextSaveGState(context);
584 | CGContextSetShadowWithColor(context, shadow2Offset, shadow2BlurRadius, shadow2);
585 | [[UIColor whiteColor] setFill];
586 | [bezierPath fill];
587 | CGContextRestoreGState(context);
588 |
589 |
590 | //// Cleanup
591 | CGGradientRelease(gradient);
592 | CGColorSpaceRelease(colorSpace);
593 |
594 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
595 | UIGraphicsEndImageContext();
596 |
597 | return image;
598 | }
599 |
600 | @end
601 |
602 | #pragma mark - UIView + Screenshot
603 |
604 | @implementation UIView (Screenshot)
605 |
606 | - (UIImage*)screenshot {
607 | UIGraphicsBeginImageContext(self.bounds.size);
608 | if( [self respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)] ){
609 | [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
610 | }else{
611 | [self.layer renderInContext:UIGraphicsGetCurrentContext()];
612 | }
613 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
614 | UIGraphicsEndImageContext();
615 |
616 | // hack, helps w/ our colors when blurring
617 | NSData *imageData = UIImageJPEGRepresentation(image, 1); // convert to jpeg
618 | image = [UIImage imageWithData:imageData];
619 |
620 | return image;
621 | }
622 |
623 | @end
624 |
625 | #pragma mark - UIImage + Blur
626 |
627 | @implementation UIImage (Blur)
628 |
629 | -(UIImage *)boxblurImageWithBlur:(CGFloat)blur {
630 | if (blur < 0.f || blur > 1.f) {
631 | blur = 0.5f;
632 | }
633 | int boxSize = (int)(blur * 40);
634 | boxSize = boxSize - (boxSize % 2) + 1;
635 |
636 | CGImageRef img = self.CGImage;
637 |
638 | vImage_Buffer inBuffer, outBuffer;
639 |
640 | vImage_Error error;
641 |
642 | void *pixelBuffer;
643 |
644 |
645 | //create vImage_Buffer with data from CGImageRef
646 |
647 | CGDataProviderRef inProvider = CGImageGetDataProvider(img);
648 | CFDataRef inBitmapData = CGDataProviderCopyData(inProvider);
649 |
650 |
651 | inBuffer.width = CGImageGetWidth(img);
652 | inBuffer.height = CGImageGetHeight(img);
653 | inBuffer.rowBytes = CGImageGetBytesPerRow(img);
654 |
655 | inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData);
656 |
657 | //create vImage_Buffer for output
658 |
659 | pixelBuffer = malloc(CGImageGetBytesPerRow(img) * CGImageGetHeight(img));
660 |
661 | if(pixelBuffer == NULL)
662 | NSLog(@"No pixelbuffer");
663 |
664 | outBuffer.data = pixelBuffer;
665 | outBuffer.width = CGImageGetWidth(img);
666 | outBuffer.height = CGImageGetHeight(img);
667 | outBuffer.rowBytes = CGImageGetBytesPerRow(img);
668 |
669 | // Create a third buffer for intermediate processing
670 | void *pixelBuffer2 = malloc(CGImageGetBytesPerRow(img) * CGImageGetHeight(img));
671 | vImage_Buffer outBuffer2;
672 | outBuffer2.data = pixelBuffer2;
673 | outBuffer2.width = CGImageGetWidth(img);
674 | outBuffer2.height = CGImageGetHeight(img);
675 | outBuffer2.rowBytes = CGImageGetBytesPerRow(img);
676 |
677 | //perform convolution
678 | error = vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer2, NULL, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend);
679 | error = vImageBoxConvolve_ARGB8888(&outBuffer2, &inBuffer, NULL, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend);
680 | error = vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, NULL, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend);
681 |
682 | if (error) {
683 | NSLog(@"error from convolution %ld", error);
684 | }
685 |
686 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
687 | CGContextRef ctx = CGBitmapContextCreate(outBuffer.data,
688 | outBuffer.width,
689 | outBuffer.height,
690 | 8,
691 | outBuffer.rowBytes,
692 | colorSpace,
693 | kCGImageAlphaNoneSkipLast);
694 | CGImageRef imageRef = CGBitmapContextCreateImage (ctx);
695 | UIImage *returnImage = [UIImage imageWithCGImage:imageRef];
696 |
697 | //clean up
698 | CGContextRelease(ctx);
699 | CGColorSpaceRelease(colorSpace);
700 | free(pixelBuffer2)
701 | free(pixelBuffer);
702 | CFRelease(inBitmapData);
703 |
704 | CGImageRelease(imageRef);
705 |
706 | return returnImage;
707 | }
708 |
709 | @end
710 |
--------------------------------------------------------------------------------
/RNBlurModalView.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'RNBlurModalView'
3 | s.version = '0.1.0'
4 | s.summary = 'Add depth to your alerts.'
5 | s.homepage = 'https://github.com/rnystrom/RNBlurModalView'
6 | s.license = 'MIT'
7 | s.author = { 'Ryan Nystrom' => 'rnystrom«whoisryannystrom.com' }
8 |
9 | s.source = { :git => 'https://github.com/rnystrom/RNBlurModalView.git', :tag => '0.1.0' }
10 | s.platform = :ios, '5.0'
11 |
12 | s.source_files = 'RNBlurModalView.{h,m}'
13 |
14 | s.requires_arc = true
15 | s.frameworks = 'QuartzCore', 'Accelerate'
16 | end
17 |
--------------------------------------------------------------------------------
/images/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rnystrom/RNBlurModalView/ddbdd9e43be24e6f43e69e41f9c8f5394e5cdf5e/images/image.jpg
--------------------------------------------------------------------------------