├── screen1.png ├── screen2.png ├── OECentreMenu ├── Supporting │ ├── quaver.png │ └── FXBlurView │ │ ├── FXBlurView.h │ │ └── FXBlurView.m ├── OECentreMenu.h └── OECentreMenu.m ├── OECentreMenuDemo ├── Resources │ └── jiveScreenshot.png ├── OECentreMenu │ ├── Supporting │ │ ├── quaver.png │ │ └── FXBlurView │ │ │ ├── FXBlurView.h │ │ │ └── FXBlurView.m │ ├── OECentreMenu.h │ └── OECentreMenu.m ├── OECentreMenuDemo │ ├── Resources │ │ └── jiveScreenshot.png │ ├── OECentreMenu │ │ ├── Supporting │ │ │ ├── quaver.png │ │ │ └── FXBlurView │ │ │ │ ├── FXBlurView.h │ │ │ │ └── FXBlurView.m │ │ ├── OECentreMenu.h │ │ └── OECentreMenu.m │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ └── ViewController.m ├── OECentreMenuDemo.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Odie.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcuserdata │ │ └── Odie.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ └── OECentreMenuDemo.xcscheme │ └── project.pbxproj └── OECentreMenuDemoTests │ ├── Info.plist │ └── OECentreMenuDemoTests.m ├── README.md └── LICENSE /screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/screen1.png -------------------------------------------------------------------------------- /screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/screen2.png -------------------------------------------------------------------------------- /OECentreMenu/Supporting/quaver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/OECentreMenu/Supporting/quaver.png -------------------------------------------------------------------------------- /OECentreMenuDemo/Resources/jiveScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/OECentreMenuDemo/Resources/jiveScreenshot.png -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenu/Supporting/quaver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/OECentreMenuDemo/OECentreMenu/Supporting/quaver.png -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/Resources/jiveScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/OECentreMenuDemo/OECentreMenuDemo/Resources/jiveScreenshot.png -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/OECentreMenu/Supporting/quaver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/OECentreMenuDemo/OECentreMenuDemo/OECentreMenu/Supporting/quaver.png -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo.xcodeproj/project.xcworkspace/xcuserdata/Odie.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oduwa/OECentreMenu/HEAD/OECentreMenuDemo/OECentreMenuDemo.xcodeproj/project.xcworkspace/xcuserdata/Odie.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OECentreMenuDemo 4 | // 5 | // Created by Odie Edo-Osagie on 05/04/2015. 6 | // Copyright (c) 2015 Odie Edo-Osagie. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | - (IBAction)leftBarButtonPressed:(id)sender; 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OECentreMenuDemo 4 | // 5 | // Created by Odie Edo-Osagie on 05/04/2015. 6 | // Copyright (c) 2015 Odie Edo-Osagie. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OECentreMenuDemo 4 | // 5 | // Created by Odie Edo-Osagie on 05/04/2015. 6 | // Copyright (c) 2015 Odie Edo-Osagie. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo.xcodeproj/xcuserdata/Odie.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OECentreMenuDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4C95EA981AD1EAC300AEF79F 16 | 17 | primary 18 | 19 | 20 | 4C95EAB11AD1EAC300AEF79F 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.odie.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemoTests/OECentreMenuDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenuDemoTests.m 3 | // OECentreMenuDemoTests 4 | // 5 | // Created by Odie Edo-Osagie on 05/04/2015. 6 | // Copyright (c) 2015 Odie Edo-Osagie. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface OECentreMenuDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation OECentreMenuDemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.odie.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OECentreMenuDemo 4 | // 5 | // Created by Odie Edo-Osagie on 05/04/2015. 6 | // Copyright (c) 2015 Odie Edo-Osagie. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /OECentreMenu/Supporting/FXBlurView/FXBlurView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FXBlurView.h 3 | // 4 | // Version 1.6.1 5 | // 6 | // Created by Nick Lockwood on 25/08/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FXBlurView 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | #import 36 | 37 | 38 | #pragma GCC diagnostic push 39 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 40 | 41 | 42 | #import 43 | #undef weak_ref 44 | #if __has_feature(objc_arc) && __has_feature(objc_arc_weak) 45 | #define weak_ref weak 46 | #else 47 | #define weak_ref unsafe_unretained 48 | #endif 49 | 50 | 51 | @interface UIImage (FXBlurView) 52 | 53 | - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor; 54 | 55 | @end 56 | 57 | 58 | @interface FXBlurView : UIView 59 | 60 | + (void)setBlurEnabled:(BOOL)blurEnabled; 61 | + (void)setUpdatesEnabled; 62 | + (void)setUpdatesDisabled; 63 | 64 | @property (nonatomic, getter = isBlurEnabled) BOOL blurEnabled; 65 | @property (nonatomic, getter = isDynamic) BOOL dynamic; 66 | @property (nonatomic, assign) NSUInteger iterations; 67 | @property (nonatomic, assign) NSTimeInterval updateInterval; 68 | @property (nonatomic, assign) CGFloat blurRadius; 69 | @property (nonatomic, strong) UIColor *tintColor; 70 | @property (nonatomic, weak_ref) UIView *underlyingView; 71 | 72 | - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion; 73 | 74 | @end 75 | 76 | 77 | #pragma GCC diagnostic pop 78 | 79 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenu/Supporting/FXBlurView/FXBlurView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FXBlurView.h 3 | // 4 | // Version 1.6.1 5 | // 6 | // Created by Nick Lockwood on 25/08/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FXBlurView 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | #import 36 | 37 | 38 | #pragma GCC diagnostic push 39 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 40 | 41 | 42 | #import 43 | #undef weak_ref 44 | #if __has_feature(objc_arc) && __has_feature(objc_arc_weak) 45 | #define weak_ref weak 46 | #else 47 | #define weak_ref unsafe_unretained 48 | #endif 49 | 50 | 51 | @interface UIImage (FXBlurView) 52 | 53 | - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor; 54 | 55 | @end 56 | 57 | 58 | @interface FXBlurView : UIView 59 | 60 | + (void)setBlurEnabled:(BOOL)blurEnabled; 61 | + (void)setUpdatesEnabled; 62 | + (void)setUpdatesDisabled; 63 | 64 | @property (nonatomic, getter = isBlurEnabled) BOOL blurEnabled; 65 | @property (nonatomic, getter = isDynamic) BOOL dynamic; 66 | @property (nonatomic, assign) NSUInteger iterations; 67 | @property (nonatomic, assign) NSTimeInterval updateInterval; 68 | @property (nonatomic, assign) CGFloat blurRadius; 69 | @property (nonatomic, strong) UIColor *tintColor; 70 | @property (nonatomic, weak_ref) UIView *underlyingView; 71 | 72 | - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion; 73 | 74 | @end 75 | 76 | 77 | #pragma GCC diagnostic pop 78 | 79 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/OECentreMenu/Supporting/FXBlurView/FXBlurView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FXBlurView.h 3 | // 4 | // Version 1.6.1 5 | // 6 | // Created by Nick Lockwood on 25/08/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FXBlurView 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import 35 | #import 36 | 37 | 38 | #pragma GCC diagnostic push 39 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 40 | 41 | 42 | #import 43 | #undef weak_ref 44 | #if __has_feature(objc_arc) && __has_feature(objc_arc_weak) 45 | #define weak_ref weak 46 | #else 47 | #define weak_ref unsafe_unretained 48 | #endif 49 | 50 | 51 | @interface UIImage (FXBlurView) 52 | 53 | - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor; 54 | 55 | @end 56 | 57 | 58 | @interface FXBlurView : UIView 59 | 60 | + (void)setBlurEnabled:(BOOL)blurEnabled; 61 | + (void)setUpdatesEnabled; 62 | + (void)setUpdatesDisabled; 63 | 64 | @property (nonatomic, getter = isBlurEnabled) BOOL blurEnabled; 65 | @property (nonatomic, getter = isDynamic) BOOL dynamic; 66 | @property (nonatomic, assign) NSUInteger iterations; 67 | @property (nonatomic, assign) NSTimeInterval updateInterval; 68 | @property (nonatomic, assign) CGFloat blurRadius; 69 | @property (nonatomic, strong) UIColor *tintColor; 70 | @property (nonatomic, weak_ref) UIView *underlyingView; 71 | 72 | - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion; 73 | 74 | @end 75 | 76 | 77 | #pragma GCC diagnostic pop 78 | 79 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // OECentreMenuDemo 4 | // 5 | // Created by Odie Edo-Osagie on 05/04/2015. 6 | // Copyright (c) 2015 Odie Edo-Osagie. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "OECentreMenu.h" 11 | 12 | @interface ViewController (){ 13 | OECentreMenu *myMenu; 14 | BOOL isMenuShowing; 15 | } 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | 25 | // menu setup 26 | [self setupMenu]; 27 | 28 | } 29 | 30 | - (void)didReceiveMemoryWarning { 31 | [super didReceiveMemoryWarning]; 32 | // Dispose of any resources that can be recreated. 33 | } 34 | 35 | - (void) setupMenu 36 | { 37 | UIButton *button1 = [[UIButton alloc] init]; 38 | [button1 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 39 | [button1 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 40 | button1.backgroundColor = [UIColor colorWithRed:26.0/256 green:188.0/256 blue:156.0/256 alpha:1.0]; 41 | 42 | UIButton *button2 = [[UIButton alloc] init]; 43 | [button2 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 44 | [button2 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 45 | button2.backgroundColor = [UIColor colorWithRed:52.0/256 green:152.0/256 blue:219.0/256 alpha:1.0]; 46 | 47 | UIButton *button3 = [[UIButton alloc] init]; 48 | [button3 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 49 | [button3 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 50 | button3.backgroundColor = [UIColor colorWithRed:246.0/256 green:71.0/256 blue:71.0/256 alpha:1.0]; 51 | 52 | UIButton *button4 = [[UIButton alloc] init]; 53 | [button4 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 54 | [button4 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 55 | button4.backgroundColor = [UIColor colorWithRed:241.0/256 green:196.0/256 blue:15.0/256 alpha:1.0]; 56 | 57 | UIButton *button5 = [[UIButton alloc] init]; 58 | [button5 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 59 | [button5 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 60 | button5.backgroundColor = [UIColor colorWithRed:155.0/256 green:89.0/256 blue:182.0/256 alpha:1.0]; 61 | 62 | UIButton *button6 = [[UIButton alloc] init]; 63 | [button6 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 64 | [button6 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 65 | button6.backgroundColor = [UIColor colorWithRed:253.0/256 green:227.0/256 blue:167.0/256 alpha:1.0]; 66 | 67 | NSArray *buttons = @[button1, button2, button3, button4, button5, button6]; 68 | 69 | myMenu = [[OECentreMenu alloc] initInViewController:self withButtons:buttons andVerticalOffset:64]; 70 | } 71 | 72 | - (void) buttonPressed 73 | { 74 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Yay!" 75 | message:@"You selected a menu item! You may navigate to another page or whatever else you like!" 76 | delegate:nil 77 | cancelButtonTitle:@"Ok" 78 | otherButtonTitles: nil]; 79 | [alert show]; 80 | } 81 | 82 | - (IBAction)leftBarButtonPressed:(id)sender 83 | { 84 | if(!isMenuShowing){ 85 | [myMenu show]; 86 | isMenuShowing = YES; 87 | } 88 | else{ 89 | [myMenu hide]; 90 | isMenuShowing = NO; 91 | } 92 | } 93 | 94 | 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo.xcodeproj/xcuserdata/Odie.xcuserdatad/xcschemes/OECentreMenuDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OECentreMenu 2 | ============ 3 | 4 | A simple drag and drop solution for an animated menu in the centre of the screen. 5 | 6 | ![alt tag](http://media.tumblr.com/62b2088d895724bd64d51e321dcdfb59/tumblr_inline_n8gxdo0NVt1sbglrf.gif) 7 | 8 | Menu Shown | Menu Dismissed 9 | :-------------------------:|:-------------------------: 10 | ![](http://i61.tinypic.com/2yzk02s.png) | ![](http://i61.tinypic.com/11jw6mr.png) 11 | 12 | 13 | ## Initialization ## 14 | The menu can be initialized in different ways depending on your preferences. The two initialization methods are 15 | ```[OECentreMenu initInViewController:withButtons:thatHasTabBar:]``` and ```[OECentreMenu initInViewController: withButtons:andVerticalOffset:]```. Examples are shown below: 16 | 17 | ```smalltalk 18 | OECentreMenu *menu = [[OECentreMenu alloc] initInViewController:self withButtons:nil thatHasTabBar:YES]; 19 | ``` 20 | 21 | or 22 | 23 | ```smalltalk 24 | OECentreMenu *menu = [[OECentreMenu alloc] initInViewController:self withButtons:nil andVerticalOffset:90]; 25 | ``` 26 | 27 | The argument for *thatHasTabBar* is a boolean value that signifies whether there is a tab bar or bottom toolbar 28 | on the view controller upon which the menu is to be displayed. This lets the method know whether to take this into account when centering the menu. 29 | 30 | The argument for *andVerticalOffset* is a float value to offset the vertical position of the menu by. A positive value 31 | moves the menu up and a negative value moves it down. 32 | 33 | Notice that in the above examples, the "withButtons:" argument is nil. The above styles of initialization do not specify any buttons for the menu or what the buttons should do. Instead, defaults buttons are placed. You may provide your own buttons or override the defaults. You will probably need to provide your own buttons. An example is shown below: 34 | 35 | 36 | ```smalltalk 37 | UIButton *button1 = [[UIButton alloc] init]; 38 | [button1 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 39 | [button1 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 40 | button1.backgroundColor = [UIColor redColor]; 41 | 42 | . . . 43 | 44 | UIButton *button6 = [[UIButton alloc] init]; 45 | [button6 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 46 | [button6 addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 47 | button6.backgroundColor = [UIColor yellowColor]; 48 | 49 | NSArray *myButtons = @[button1, button2, button3, button4, button5, button6]; 50 | 51 | OECentreMenu *menu = [[OECentreMenu alloc] initInViewController:self withButtons:buttons thatHasTabBar:YES]; 52 | 53 | // Alternatively the line below can be used to specify the vertical offset of the Menu 54 | //OECentreMenu *menu = [[OECentreMenu alloc] initInViewController:self withButtons:buttons andVerticalOffset:90]; 55 | ``` 56 | Don't forget to replace "quaver.png" with whatever image you have/want. 57 | 58 | You also do not have to provide 6 buttons. You may provide any number of buttons. Any buttons you do not provide will be replaced with the default placeholder. 59 | 60 | ## Usage ## 61 | To display the menu, call: 62 | ```smalltalk 63 | [myMenu show]; 64 | ``` 65 | To hide the menu, call: 66 | ```smalltalk 67 | [myMenu hide]; 68 | ``` 69 | "myMenu" in the above example, is an instance of OECentreMenu (which i suggest should be a private instance variable). 70 | 71 | ### Device Rotation ### 72 | 73 | If your View Controller supports device rotation, you may want the menu to rotate with the rest of the screen. 74 | To accomplish this, implement the delegate method -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 75 | within the View Controller making use of the menu. An example is shown below: 76 | 77 | ```smalltalk 78 | - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 79 | { 80 | [myMenu updateFramesAfterDeviceRotation]; 81 | } 82 | ``` 83 | 84 | "myMenu" in the above example, is an instance of OECentreMenu (which i suggest should be a private instance variable). 85 | 86 | ** WARNING: Calling this method within -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation:duration:(NSTimeInterval)duration on the other hand, will not have any effect.** 87 | 88 | 89 | ### Customization ### 90 | 91 | - The background of the menu can be hidden by calling the ```setShowsBackgroundFrame:(BOOL)hasFrame``` method. Setting *hasFrame* to NO hides the background of the Menu. 92 | - The blur effect on the Menu background can be removed by calling the ```setBackgroundBlurEnabled:(BOOL) enabled``` method. Setting *enabled* to NO removes the blur effect. 93 | - The colour of the menu background can be changed by calling the ```changeBackgroundColour:(UIColor *)backgroundColour``` method. *backgroundColour* should be the new colour to be set to the Menu background. 94 | 95 | 96 | 97 | 98 | ## Compatibility ## 99 | 100 | Tested and working on iOS 6.1+ 101 | 102 | ## Credits ## 103 | 104 | Special thanks to Nick Lockwood. I used his [FXBlurView](https://github.com/nicklockwood/FXBlurView). 105 | 106 | That's all folks! 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /OECentreMenu/OECentreMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenu.m 3 | // 4 | // Created by Odie Edo-Osagie on 09/07/2014. 5 | // Copyright (c) 2014 Odie Edo-Osagie. All rights reserved. 6 | // 7 | // Get the latest version from here: 8 | // 9 | // https://github.com/oduwa/OECentreMenu 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would be 22 | // appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not be 25 | // misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source distribution. 28 | // 29 | 30 | #import 31 | 32 | @interface OECentreMenu : NSObject 33 | 34 | /* MENU BACKGROUND */ 35 | @property (nonatomic, strong) UIView *backgroundView; 36 | @property (nonatomic, strong) UIView *regularBackgroundView; 37 | @property (nonatomic, strong) UIView *blurredBackgroundView; 38 | @property (nonatomic, assign) CGRect initialBackgroundFrame; 39 | @property (nonatomic, assign) CGRect finalBackgroundFrame; 40 | 41 | /* FIRST MENU ITEM */ 42 | @property (nonatomic, strong) UIButton *item1; 43 | @property (nonatomic, assign) CGRect initialItem1Frame; 44 | @property (nonatomic, assign) CGRect finalItem1Frame; 45 | 46 | /* SECOND MENU ITEM */ 47 | @property (nonatomic, strong) UIButton *item2; 48 | @property (nonatomic, assign) CGRect initialItem2Frame; 49 | @property (nonatomic, assign) CGRect finalItem2Frame; 50 | 51 | /* THIRD MENU ITEM */ 52 | @property (nonatomic, strong) UIButton *item3; 53 | @property (nonatomic, assign) CGRect initialItem3Frame; 54 | @property (nonatomic, assign) CGRect finalItem3Frame; 55 | 56 | /* FOURTH MENU ITEM */ 57 | @property (nonatomic, strong) UIButton *item4; 58 | @property (nonatomic, assign) CGRect initialItem4Frame; 59 | @property (nonatomic, assign) CGRect finalItem4Frame; 60 | 61 | /* FIFTH MENU ITEM */ 62 | @property (nonatomic, strong) UIButton *item5; 63 | @property (nonatomic, assign) CGRect initialItem5Frame; 64 | @property (nonatomic, assign) CGRect finalItem5Frame; 65 | 66 | /* SIXTH MENU ITEM */ 67 | @property (nonatomic, strong) UIButton *item6; 68 | @property (nonatomic, assign) CGRect initialItem6Frame; 69 | @property (nonatomic, assign) CGRect finalItem6Frame; 70 | 71 | /** 72 | * The View Controller within which this OECentreMenu is contained. 73 | */ 74 | @property (nonatomic, strong) UIViewController *vc; 75 | 76 | /** 77 | * A boolean flag that signifies whether there is a tab bar or bottom toolbar 78 | * on vc so the method knows whether to take this into account when centering the menu. 79 | */ 80 | @property (nonatomic, assign) BOOL hasTabBar; 81 | 82 | /** 83 | * A float value to offset the vertical position of the menu by. A positive value 84 | * moves the menu up and a negative value moves it down. 85 | */ 86 | @property (nonatomic, assign) float centreOffSet_vertical; 87 | 88 | /** 89 | * The colour of the background of the Menu. 90 | */ 91 | @property (nonatomic, strong) UIColor *backgroundColour; 92 | 93 | /** 94 | * The colour of the blur effect of the Menu. 95 | */ 96 | @property (nonatomic, strong) UIColor *transparentTintColour; 97 | 98 | 99 | /* INITIALIZATION */ 100 | 101 | /** 102 | * Initializes and arranges the Centre Menu. 103 | * 104 | * @param vc The View Controller within which the Menu is to be displayed. 105 | * @param buttons An array of UIButton objects to be placed within the menu. 106 | * The UIButton at index 0 is for the button at the top left, 1 is for top center, 107 | * and 5 is for bottom right. The array may be nil, empty or contain less than 6 buttons. 108 | * In such a scenario, default buttons are created. 109 | * @param yValue A float value to offset the vertical position of the menu by. A positive value 110 | * moves the menu up and a negative value moves it down. 111 | * 112 | */ 113 | - (id) initInViewController: (UIViewController *)vc withButtons:(NSArray *)buttons andVerticalOffset: (float)yValue; 114 | 115 | /** 116 | * Initializes and arranges the Centre Menu. 117 | * 118 | * @param vc The View Controller within which the Menu is to be displayed. 119 | * @param buttons An array of UIButton objects to be placed within the menu. 120 | * The UIButton at index 0 is for the button at the top left, 1 is for top center, 121 | * and 5 is for bottom right. The array may be nil, empty or contain less than 6 buttons. 122 | * In such a scenario, default buttons are created. 123 | * @param hasTabBar A boolean flag that signifies whether there is a tab bar or bottom toolbar 124 | * on vc so the method knows whether to take this into account when centering the menu. 125 | * 126 | */ 127 | - (id) initInViewController: (UIViewController *)vc withButtons: (NSArray *)buttons thatHasTabBar: (BOOL) hasTabBar; 128 | 129 | 130 | 131 | /* PRESENTATION */ 132 | 133 | /** 134 | * Animates the Menu into display. 135 | * 136 | * The Menu must first have been initialized at some point. 137 | * Otherwise, this method will throw an Exception. 138 | */ 139 | - (void) show; 140 | 141 | 142 | /** 143 | * Animates the Menu out of display. 144 | * 145 | * The Menu must first have been initialized at some point. 146 | * Otherwise, this method will throw an Exception. 147 | */ 148 | - (void) hide; 149 | 150 | 151 | /** 152 | * Updates the position of the menu for re-centering after the device has been 153 | * rotated. 154 | * 155 | * To use this method, implement the 156 | * @a -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 157 | * method within the View Controller making use of the menu. This method should 158 | * then be called within your implementation. 159 | * 160 | * @warning Calling this method within 161 | * @a -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation@a duration:(NSTimeInterval)duration 162 | * on the other hand, will not have any effect. 163 | */ 164 | - (void) updateFramesAfterDeviceRotation; 165 | 166 | 167 | 168 | /* SETTERS */ 169 | 170 | /** 171 | * Sets whether or not the background of the Menu is visible or not. 172 | * 173 | * @param enabled set to NO to hide the background of the Menu. 174 | * 175 | */ 176 | - (void) setShowsBackgroundFrame:(BOOL) hasFrame; 177 | 178 | 179 | /** 180 | * Sets whether or not the background of the Menu should have a blur effect or not. 181 | * 182 | * @param enabled set to YES to add a blur effect the background of the menu 183 | * 184 | */ 185 | - (void) setBackgroundBlurEnabled:(BOOL) enabled; 186 | 187 | 188 | /** 189 | * Changes the colour of the background of the Menu. 190 | * 191 | *@param backgroundColour the new colour to be set to the Menu background. 192 | * 193 | */ 194 | - (void) changeBackgroundColour:(UIColor *)backgroundColour; 195 | 196 | 197 | /** 198 | * Changes the colour of the blur effect of the Menu. 199 | * 200 | *@param backgroundColour the new colour to be set to the blur effect of the Menu background. 201 | * 202 | */ 203 | - (void) changeTransparentTintColour:(UIColor *)transparentTintColour; 204 | 205 | 206 | 207 | 208 | 209 | @end 210 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenu/OECentreMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenu.m 3 | // 4 | // Created by Odie Edo-Osagie on 09/07/2014. 5 | // Copyright (c) 2014 Odie Edo-Osagie. All rights reserved. 6 | // 7 | // Get the latest version from here: 8 | // 9 | // https://github.com/oduwa/OECentreMenu 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would be 22 | // appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not be 25 | // misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source distribution. 28 | // 29 | 30 | #import 31 | 32 | @interface OECentreMenu : NSObject 33 | 34 | /* MENU BACKGROUND */ 35 | @property (nonatomic, strong) UIView *backgroundView; 36 | @property (nonatomic, strong) UIView *regularBackgroundView; 37 | @property (nonatomic, strong) UIView *blurredBackgroundView; 38 | @property (nonatomic, assign) CGRect initialBackgroundFrame; 39 | @property (nonatomic, assign) CGRect finalBackgroundFrame; 40 | 41 | /* FIRST MENU ITEM */ 42 | @property (nonatomic, strong) UIButton *item1; 43 | @property (nonatomic, assign) CGRect initialItem1Frame; 44 | @property (nonatomic, assign) CGRect finalItem1Frame; 45 | 46 | /* SECOND MENU ITEM */ 47 | @property (nonatomic, strong) UIButton *item2; 48 | @property (nonatomic, assign) CGRect initialItem2Frame; 49 | @property (nonatomic, assign) CGRect finalItem2Frame; 50 | 51 | /* THIRD MENU ITEM */ 52 | @property (nonatomic, strong) UIButton *item3; 53 | @property (nonatomic, assign) CGRect initialItem3Frame; 54 | @property (nonatomic, assign) CGRect finalItem3Frame; 55 | 56 | /* FOURTH MENU ITEM */ 57 | @property (nonatomic, strong) UIButton *item4; 58 | @property (nonatomic, assign) CGRect initialItem4Frame; 59 | @property (nonatomic, assign) CGRect finalItem4Frame; 60 | 61 | /* FIFTH MENU ITEM */ 62 | @property (nonatomic, strong) UIButton *item5; 63 | @property (nonatomic, assign) CGRect initialItem5Frame; 64 | @property (nonatomic, assign) CGRect finalItem5Frame; 65 | 66 | /* SIXTH MENU ITEM */ 67 | @property (nonatomic, strong) UIButton *item6; 68 | @property (nonatomic, assign) CGRect initialItem6Frame; 69 | @property (nonatomic, assign) CGRect finalItem6Frame; 70 | 71 | /** 72 | * The View Controller within which this OECentreMenu is contained. 73 | */ 74 | @property (nonatomic, strong) UIViewController *vc; 75 | 76 | /** 77 | * A boolean flag that signifies whether there is a tab bar or bottom toolbar 78 | * on vc so the method knows whether to take this into account when centering the menu. 79 | */ 80 | @property (nonatomic, assign) BOOL hasTabBar; 81 | 82 | /** 83 | * A float value to offset the vertical position of the menu by. A positive value 84 | * moves the menu up and a negative value moves it down. 85 | */ 86 | @property (nonatomic, assign) float centreOffSet_vertical; 87 | 88 | /** 89 | * The colour of the background of the Menu. 90 | */ 91 | @property (nonatomic, strong) UIColor *backgroundColour; 92 | 93 | /** 94 | * The colour of the blur effect of the Menu. 95 | */ 96 | @property (nonatomic, strong) UIColor *transparentTintColour; 97 | 98 | 99 | /* INITIALIZATION */ 100 | 101 | /** 102 | * Initializes and arranges the Centre Menu. 103 | * 104 | * @param vc The View Controller within which the Menu is to be displayed. 105 | * @param buttons An array of UIButton objects to be placed within the menu. 106 | * The UIButton at index 0 is for the button at the top left, 1 is for top center, 107 | * and 5 is for bottom right. The array may be nil, empty or contain less than 6 buttons. 108 | * In such a scenario, default buttons are created. 109 | * @param yValue A float value to offset the vertical position of the menu by. A positive value 110 | * moves the menu up and a negative value moves it down. 111 | * 112 | */ 113 | - (id) initInViewController: (UIViewController *)vc withButtons:(NSArray *)buttons andVerticalOffset: (float)yValue; 114 | 115 | /** 116 | * Initializes and arranges the Centre Menu. 117 | * 118 | * @param vc The View Controller within which the Menu is to be displayed. 119 | * @param buttons An array of UIButton objects to be placed within the menu. 120 | * The UIButton at index 0 is for the button at the top left, 1 is for top center, 121 | * and 5 is for bottom right. The array may be nil, empty or contain less than 6 buttons. 122 | * In such a scenario, default buttons are created. 123 | * @param hasTabBar A boolean flag that signifies whether there is a tab bar or bottom toolbar 124 | * on vc so the method knows whether to take this into account when centering the menu. 125 | * 126 | */ 127 | - (id) initInViewController: (UIViewController *)vc withButtons: (NSArray *)buttons thatHasTabBar: (BOOL) hasTabBar; 128 | 129 | 130 | 131 | /* PRESENTATION */ 132 | 133 | /** 134 | * Animates the Menu into display. 135 | * 136 | * The Menu must first have been initialized at some point. 137 | * Otherwise, this method will throw an Exception. 138 | */ 139 | - (void) show; 140 | 141 | 142 | /** 143 | * Animates the Menu out of display. 144 | * 145 | * The Menu must first have been initialized at some point. 146 | * Otherwise, this method will throw an Exception. 147 | */ 148 | - (void) hide; 149 | 150 | 151 | /** 152 | * Updates the position of the menu for re-centering after the device has been 153 | * rotated. 154 | * 155 | * To use this method, implement the 156 | * @a -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 157 | * method within the View Controller making use of the menu. This method should 158 | * then be called within your implementation. 159 | * 160 | * @warning Calling this method within 161 | * @a -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation@a duration:(NSTimeInterval)duration 162 | * on the other hand, will not have any effect. 163 | */ 164 | - (void) updateFramesAfterDeviceRotation; 165 | 166 | 167 | 168 | /* SETTERS */ 169 | 170 | /** 171 | * Sets whether or not the background of the Menu is visible or not. 172 | * 173 | * @param enabled set to NO to hide the background of the Menu. 174 | * 175 | */ 176 | - (void) setShowsBackgroundFrame:(BOOL) hasFrame; 177 | 178 | 179 | /** 180 | * Sets whether or not the background of the Menu should have a blur effect or not. 181 | * 182 | * @param enabled set to YES to add a blur effect the background of the menu 183 | * 184 | */ 185 | - (void) setBackgroundBlurEnabled:(BOOL) enabled; 186 | 187 | 188 | /** 189 | * Changes the colour of the background of the Menu. 190 | * 191 | *@param backgroundColour the new colour to be set to the Menu background. 192 | * 193 | */ 194 | - (void) changeBackgroundColour:(UIColor *)backgroundColour; 195 | 196 | 197 | /** 198 | * Changes the colour of the blur effect of the Menu. 199 | * 200 | *@param backgroundColour the new colour to be set to the blur effect of the Menu background. 201 | * 202 | */ 203 | - (void) changeTransparentTintColour:(UIColor *)transparentTintColour; 204 | 205 | 206 | 207 | 208 | 209 | @end 210 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/OECentreMenu/OECentreMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenu.m 3 | // 4 | // Created by Odie Edo-Osagie on 09/07/2014. 5 | // Copyright (c) 2014 Odie Edo-Osagie. All rights reserved. 6 | // 7 | // Get the latest version from here: 8 | // 9 | // https://github.com/oduwa/OECentreMenu 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would be 22 | // appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not be 25 | // misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source distribution. 28 | // 29 | 30 | #import 31 | #import 32 | 33 | @interface OECentreMenu : NSObject 34 | 35 | /* MENU BACKGROUND */ 36 | @property (nonatomic, strong) UIView *backgroundView; 37 | @property (nonatomic, strong) UIView *regularBackgroundView; 38 | @property (nonatomic, strong) UIView *blurredBackgroundView; 39 | @property (nonatomic, assign) CGRect initialBackgroundFrame; 40 | @property (nonatomic, assign) CGRect finalBackgroundFrame; 41 | 42 | /* FIRST MENU ITEM */ 43 | @property (nonatomic, strong) UIButton *item1; 44 | @property (nonatomic, assign) CGRect initialItem1Frame; 45 | @property (nonatomic, assign) CGRect finalItem1Frame; 46 | 47 | /* SECOND MENU ITEM */ 48 | @property (nonatomic, strong) UIButton *item2; 49 | @property (nonatomic, assign) CGRect initialItem2Frame; 50 | @property (nonatomic, assign) CGRect finalItem2Frame; 51 | 52 | /* THIRD MENU ITEM */ 53 | @property (nonatomic, strong) UIButton *item3; 54 | @property (nonatomic, assign) CGRect initialItem3Frame; 55 | @property (nonatomic, assign) CGRect finalItem3Frame; 56 | 57 | /* FOURTH MENU ITEM */ 58 | @property (nonatomic, strong) UIButton *item4; 59 | @property (nonatomic, assign) CGRect initialItem4Frame; 60 | @property (nonatomic, assign) CGRect finalItem4Frame; 61 | 62 | /* FIFTH MENU ITEM */ 63 | @property (nonatomic, strong) UIButton *item5; 64 | @property (nonatomic, assign) CGRect initialItem5Frame; 65 | @property (nonatomic, assign) CGRect finalItem5Frame; 66 | 67 | /* SIXTH MENU ITEM */ 68 | @property (nonatomic, strong) UIButton *item6; 69 | @property (nonatomic, assign) CGRect initialItem6Frame; 70 | @property (nonatomic, assign) CGRect finalItem6Frame; 71 | 72 | /** 73 | * The View Controller within which this OECentreMenu is contained. 74 | */ 75 | @property (nonatomic, strong) UIViewController *vc; 76 | 77 | /** 78 | * A boolean flag that signifies whether there is a tab bar or bottom toolbar 79 | * on vc so the method knows whether to take this into account when centering the menu. 80 | */ 81 | @property (nonatomic, assign) BOOL hasTabBar; 82 | 83 | /** 84 | * A float value to offset the vertical position of the menu by. A positive value 85 | * moves the menu up and a negative value moves it down. 86 | */ 87 | @property (nonatomic, assign) float centreOffSet_vertical; 88 | 89 | /** 90 | * The colour of the background of the Menu. 91 | */ 92 | @property (nonatomic, strong) UIColor *backgroundColour; 93 | 94 | /** 95 | * The colour of the blur effect of the Menu. 96 | */ 97 | @property (nonatomic, strong) UIColor *transparentTintColour; 98 | 99 | 100 | /* INITIALIZATION */ 101 | 102 | /** 103 | * Initializes and arranges the Centre Menu. 104 | * 105 | * @param vc The View Controller within which the Menu is to be displayed. 106 | * @param buttons An array of UIButton objects to be placed within the menu. 107 | * The UIButton at index 0 is for the button at the top left, 1 is for top center, 108 | * and 5 is for bottom right. The array may be nil, empty or contain less than 6 buttons. 109 | * In such a scenario, default buttons are created. 110 | * @param yValue A float value to offset the vertical position of the menu by. A positive value 111 | * moves the menu up and a negative value moves it down. 112 | * 113 | */ 114 | - (id) initInViewController: (UIViewController *)vc withButtons:(NSArray *)buttons andVerticalOffset: (float)yValue; 115 | 116 | /** 117 | * Initializes and arranges the Centre Menu. 118 | * 119 | * @param vc The View Controller within which the Menu is to be displayed. 120 | * @param buttons An array of UIButton objects to be placed within the menu. 121 | * The UIButton at index 0 is for the button at the top left, 1 is for top center, 122 | * and 5 is for bottom right. The array may be nil, empty or contain less than 6 buttons. 123 | * In such a scenario, default buttons are created. 124 | * @param hasTabBar A boolean flag that signifies whether there is a tab bar or bottom toolbar 125 | * on vc so the method knows whether to take this into account when centering the menu. 126 | * 127 | */ 128 | - (id) initInViewController: (UIViewController *)vc withButtons: (NSArray *)buttons thatHasTabBar: (BOOL) hasTabBar; 129 | 130 | 131 | 132 | /* PRESENTATION */ 133 | 134 | /** 135 | * Animates the Menu into display. 136 | * 137 | * The Menu must first have been initialized at some point. 138 | * Otherwise, this method will throw an Exception. 139 | */ 140 | - (void) show; 141 | 142 | 143 | /** 144 | * Animates the Menu out of display. 145 | * 146 | * The Menu must first have been initialized at some point. 147 | * Otherwise, this method will throw an Exception. 148 | */ 149 | - (void) hide; 150 | 151 | 152 | /** 153 | * Updates the position of the menu for re-centering after the device has been 154 | * rotated. 155 | * 156 | * To use this method, implement the 157 | * @a -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 158 | * method within the View Controller making use of the menu. This method should 159 | * then be called within your implementation. 160 | * 161 | * @warning Calling this method within 162 | * @a -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation@a duration:(NSTimeInterval)duration 163 | * on the other hand, will not have any effect. 164 | */ 165 | - (void) updateFramesAfterDeviceRotation; 166 | 167 | 168 | 169 | /* SETTERS */ 170 | 171 | /** 172 | * Sets whether or not the background of the Menu is visible or not. 173 | * 174 | * @param enabled set to NO to hide the background of the Menu. 175 | * 176 | */ 177 | - (void) setShowsBackgroundFrame:(BOOL) hasFrame; 178 | 179 | 180 | /** 181 | * Sets whether or not the background of the Menu should have a blur effect or not. 182 | * 183 | * @param enabled set to YES to add a blur effect the background of the menu 184 | * 185 | */ 186 | - (void) setBackgroundBlurEnabled:(BOOL) enabled; 187 | 188 | 189 | /** 190 | * Changes the colour of the background of the Menu. 191 | * 192 | *@param backgroundColour the new colour to be set to the Menu background. 193 | * 194 | */ 195 | - (void) changeBackgroundColour:(UIColor *)backgroundColour; 196 | 197 | 198 | /** 199 | * Changes the colour of the blur effect of the Menu. 200 | * 201 | *@param backgroundColour the new colour to be set to the blur effect of the Menu background. 202 | * 203 | */ 204 | - (void) changeTransparentTintColour:(UIColor *)transparentTintColour; 205 | 206 | 207 | 208 | 209 | 210 | @end 211 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/OECentreMenu/OECentreMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenu.m 3 | // 4 | // Created by Odie Edo-Osagie on 09/07/2014. 5 | // Copyright (c) 2014 Odie Edo-Osagie. All rights reserved. 6 | // 7 | // Get the latest version from here: 8 | // 9 | // https://github.com/oduwa/OECentreMenu 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would be 22 | // appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not be 25 | // misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source distribution. 28 | // 29 | 30 | #import "OECentreMenu.h" 31 | #import "FXBlurView.h" 32 | #import 33 | 34 | #define DEVICE_SIZE [[[[UIApplication sharedApplication] keyWindow] rootViewController].view convertRect:[[UIScreen mainScreen] bounds] fromView:nil].size 35 | 36 | #define COLOUR_PURPLE_STUDIO [AppUtils colorWithHexString:@"#8E44AD"]; 37 | #define COLOUR_PURPLE_REBECCAPURPLE [AppUtils colorWithHexString:@"#663399"]; 38 | #define COLOUR_PURPLE_HONEYFLOWER [AppUtils colorWithHexString:@"#674172"]; 39 | 40 | 41 | @implementation OECentreMenu 42 | 43 | 44 | #pragma mark - Initialization 45 | 46 | - (instancetype) init 47 | { 48 | self = [super init]; 49 | 50 | if(self){ 51 | _backgroundView = [[UIView alloc] init]; 52 | _initialBackgroundFrame = CGRectZero; 53 | _finalBackgroundFrame = CGRectZero; 54 | 55 | _item1 = [[UIButton alloc] init]; 56 | _initialItem1Frame = CGRectZero; 57 | _finalItem1Frame = CGRectZero; 58 | 59 | _item2 = [[UIButton alloc] init]; 60 | _initialItem2Frame = CGRectZero; 61 | _finalItem2Frame = CGRectZero; 62 | 63 | _item3 = [[UIButton alloc] init]; 64 | _initialItem3Frame = CGRectZero; 65 | _finalItem3Frame = CGRectZero; 66 | 67 | _item4 = [[UIButton alloc] init]; 68 | _initialItem4Frame = CGRectZero; 69 | _finalItem4Frame = CGRectZero; 70 | 71 | _item5 = [[UIButton alloc] init]; 72 | _initialItem5Frame = CGRectZero; 73 | _finalItem5Frame = CGRectZero; 74 | 75 | _item6 = [[UIButton alloc] init]; 76 | _initialItem6Frame = CGRectZero; 77 | _finalItem6Frame = CGRectZero; 78 | } 79 | 80 | return self; 81 | } 82 | 83 | 84 | - (id) initInViewController: (UIViewController *)vc withButtons:(NSArray *)buttons andVerticalOffset: (float)yValue 85 | { 86 | return [self initPrivatelyWithController:vc andButtons:buttons andOffSet:yValue]; 87 | } 88 | 89 | - (id) initInViewController: (UIViewController *)vc withButtons: (NSArray *)buttons thatHasTabBar: (BOOL) hasTabBar 90 | { 91 | int tabBarHeight; 92 | 93 | if(!hasTabBar){ 94 | tabBarHeight = 0; 95 | } 96 | else{ 97 | tabBarHeight = 49; 98 | } 99 | 100 | if([vc isKindOfClass:[UITableViewController class]]){ 101 | tabBarHeight += 70; 102 | } 103 | 104 | return [self initPrivatelyWithController:vc andButtons:buttons andOffSet:tabBarHeight]; 105 | } 106 | 107 | - (id) initPrivatelyWithController: (UIViewController *)vc andButtons: (NSArray *) buttons andOffSet: (float) yValue 108 | { 109 | self = [self init]; 110 | 111 | self.vc = vc; 112 | self.centreOffSet_vertical = yValue; 113 | self.backgroundColour = [UIColor colorWithRed:92 green:36 blue:100 alpha:0.8]; 114 | self.transparentTintColour = [UIColor cyanColor]; 115 | 116 | 117 | /* Background View */ 118 | _initialBackgroundFrame = CGRectMake(DEVICE_SIZE.width+20, (DEVICE_SIZE.height/2)-yValue, 10, 10); 119 | _finalBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2)-80-20, (DEVICE_SIZE.height/2)-yValue-20, 210, 140); 120 | _backgroundView = [[FXBlurView alloc] init]; 121 | [_backgroundView setFrame:_initialBackgroundFrame]; 122 | _backgroundView.layer.cornerRadius = 5.0f; 123 | _backgroundView.tintColor = self.transparentTintColour; 124 | [vc.view addSubview:_backgroundView]; 125 | 126 | _regularBackgroundView = [[UIView alloc] initWithFrame:_initialBackgroundFrame]; 127 | _regularBackgroundView.layer.cornerRadius = 5.0f; 128 | _regularBackgroundView.backgroundColor = self.backgroundColour; 129 | [vc.view addSubview:_regularBackgroundView]; 130 | 131 | _blurredBackgroundView = _backgroundView; 132 | 133 | /* top left */ 134 | _finalItem1Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-yValue, 50, 50); 135 | _initialItem1Frame = CGRectMake(-50, -50, 50, 50); 136 | if([buttons count] < 1){ 137 | _item1 = [[UIButton alloc] init]; 138 | _item1.backgroundColor = [UIColor redColor]; 139 | [_item1 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 140 | [_item1 addTarget:self 141 | action:@selector(buttonPressed) 142 | forControlEvents:UIControlEventTouchUpInside]; 143 | } 144 | else{ 145 | _item1 = buttons[0]; 146 | } 147 | [_item1 setFrame:_initialItem1Frame]; 148 | _item1.layer.cornerRadius = 25.0; 149 | _item1.clipsToBounds = YES; 150 | [vc.view addSubview:_item1]; 151 | 152 | /* top center */ 153 | _finalItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-yValue, 50, 50); 154 | _initialItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, -50, 50, 50); 155 | if([buttons count] < 2){ 156 | _item2 = [[UIButton alloc] init]; 157 | _item2.backgroundColor = [UIColor yellowColor]; 158 | [_item2 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 159 | [_item2 addTarget:self 160 | action:@selector(buttonPressed) 161 | forControlEvents:UIControlEventTouchUpInside]; 162 | } 163 | else{ 164 | _item2 = buttons[1]; 165 | } 166 | [_item2 setFrame:_initialItem2Frame]; 167 | _item2.layer.cornerRadius = 25.0; 168 | _item2.clipsToBounds = YES; 169 | [vc.view addSubview:_item2]; 170 | 171 | /* top right */ 172 | _finalItem3Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-yValue, 50, 50); 173 | _initialItem3Frame = CGRectMake(DEVICE_SIZE.width+20, -50, 50, 50); 174 | if([buttons count] < 3){ 175 | _item3 = [[UIButton alloc] init]; 176 | _item3.backgroundColor = [UIColor blueColor]; 177 | [_item3 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 178 | [_item3 addTarget:self 179 | action:@selector(buttonPressed) 180 | forControlEvents:UIControlEventTouchUpInside]; 181 | } 182 | else{ 183 | _item3 = buttons[2]; 184 | } 185 | [_item3 setFrame:_initialItem3Frame]; 186 | _item3.layer.cornerRadius = 25.0; 187 | _item3.clipsToBounds = YES; 188 | [vc.view addSubview:_item3]; 189 | 190 | /* bottom left */ 191 | _finalItem4Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 192 | _initialItem4Frame = CGRectMake(-50, DEVICE_SIZE.height+50-yValue, 50, 50); 193 | if([buttons count] < 4){ 194 | _item4 = [[UIButton alloc] init]; 195 | _item4.backgroundColor = [UIColor orangeColor]; 196 | [_item4 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 197 | [_item4 addTarget:self 198 | action:@selector(buttonPressed) 199 | forControlEvents:UIControlEventTouchUpInside]; 200 | } 201 | else{ 202 | _item4 = buttons[3]; 203 | } 204 | [_item4 setFrame:_initialItem4Frame]; 205 | _item4.layer.cornerRadius = 25.0; 206 | _item4.clipsToBounds = YES; 207 | [vc.view addSubview:_item4]; 208 | 209 | /* bottom center */ 210 | _finalItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 211 | _initialItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, DEVICE_SIZE.height+50, 50, 50); 212 | if([buttons count] < 5){ 213 | _item5 = [[UIButton alloc] init]; 214 | _item5.backgroundColor = [UIColor cyanColor]; 215 | [_item5 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 216 | [_item5 addTarget:self 217 | action:@selector(buttonPressed) 218 | forControlEvents:UIControlEventTouchUpInside]; 219 | } 220 | else{ 221 | _item5 = buttons[4]; 222 | } 223 | [_item5 setFrame:_initialItem5Frame]; 224 | _item5.layer.cornerRadius = 25.0; 225 | _item5.clipsToBounds = YES; 226 | [vc.view addSubview:_item5]; 227 | 228 | 229 | /* bottom right */ 230 | _finalItem6Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 231 | _initialItem6Frame = CGRectMake(DEVICE_SIZE.width+20, DEVICE_SIZE.height+50-yValue, 50, 50); 232 | if([buttons count] < 6){ 233 | _item6 = [[UIButton alloc] init]; 234 | _item6.backgroundColor = [UIColor magentaColor]; 235 | [_item6 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 236 | [_item6 addTarget:self 237 | action:@selector(buttonPressed) 238 | forControlEvents:UIControlEventTouchUpInside]; 239 | } 240 | else{ 241 | _item6 = buttons[5]; 242 | } 243 | [_item6 setFrame:_initialItem6Frame]; 244 | _item6.layer.cornerRadius = 25.0; 245 | _item6.clipsToBounds = YES; 246 | [vc.view addSubview:_item6]; 247 | 248 | [self hide]; 249 | 250 | return self; 251 | } 252 | 253 | #pragma mark - Presentation 254 | 255 | - (void) show 256 | { 257 | 258 | if(!self){ 259 | [NSException raise:@"UninitializedMenuException" format:@"Attempting to show menu without first initializing one."]; 260 | } 261 | 262 | [self addToDisplay]; 263 | 264 | [UIView animateWithDuration:0.2 animations:^{ 265 | _backgroundView.frame = _finalBackgroundFrame; 266 | }]; 267 | 268 | [self runSpinAnimationOnView:_item1 duration:3 rotations:4 repeat:HUGE_VALF]; 269 | [UIView animateWithDuration:0.4 animations:^{ 270 | [_item1 setFrame:_finalItem1Frame]; 271 | } completion:^(BOOL finished) { 272 | [_item1.layer removeAllAnimations]; 273 | }]; 274 | 275 | [self runSpinAnimationOnView:_item2 duration:3 rotations:4 repeat:HUGE_VALF]; 276 | [UIView animateWithDuration:0.4 animations:^{ 277 | [_item2 setFrame:_finalItem2Frame]; 278 | } completion:^(BOOL finished) { 279 | [_item2.layer removeAllAnimations]; 280 | }]; 281 | 282 | [self runSpinAnimationOnView:_item3 duration:3 rotations:4 repeat:HUGE_VALF]; 283 | [UIView animateWithDuration:0.4 animations:^{ 284 | [_item3 setFrame:_finalItem3Frame]; 285 | } completion:^(BOOL finished) { 286 | [_item3.layer removeAllAnimations]; 287 | }]; 288 | 289 | [self runSpinAnimationOnView:_item4 duration:3 rotations:4 repeat:HUGE_VALF]; 290 | [UIView animateWithDuration:0.4 animations:^{ 291 | [_item4 setFrame:_finalItem4Frame]; 292 | } completion:^(BOOL finished) { 293 | [_item4.layer removeAllAnimations]; 294 | }]; 295 | 296 | [self runSpinAnimationOnView:_item5 duration:3 rotations:4 repeat:HUGE_VALF]; 297 | [UIView animateWithDuration:0.4 animations:^{ 298 | [_item5 setFrame:_finalItem5Frame]; 299 | } completion:^(BOOL finished) { 300 | [_item5.layer removeAllAnimations]; 301 | }]; 302 | 303 | [self runSpinAnimationOnView:_item6 duration:3 rotations:4 repeat:HUGE_VALF]; 304 | [UIView animateWithDuration:0.4 animations:^{ 305 | _item6.frame = _finalItem6Frame; 306 | } completion:^(BOOL finished) { 307 | [_item6.layer removeAllAnimations]; 308 | }]; 309 | 310 | } 311 | 312 | 313 | - (void) hide 314 | { 315 | 316 | if(!self){ 317 | [NSException raise:@"UninitializedMenuException" format:@"Attempting to hide menu without first initializing one."]; 318 | } 319 | 320 | [UIView animateWithDuration:0.2 animations:^{ 321 | _backgroundView.frame = _initialBackgroundFrame; 322 | }]; 323 | 324 | [self runSpinAnimationOnView:_item1 duration:3 rotations:4 repeat:HUGE_VALF]; 325 | [UIView animateWithDuration:0.4 animations:^{ 326 | [_item1 setFrame:_initialItem1Frame]; 327 | } completion:^(BOOL finished) { 328 | [_item1.layer removeAllAnimations]; 329 | }]; 330 | 331 | [self runSpinAnimationOnView:_item2 duration:3 rotations:4 repeat:HUGE_VALF]; 332 | [UIView animateWithDuration:0.4 animations:^{ 333 | [_item2 setFrame:_initialItem2Frame]; 334 | } completion:^(BOOL finished) { 335 | [_item2.layer removeAllAnimations]; 336 | }]; 337 | 338 | [self runSpinAnimationOnView:_item3 duration:3 rotations:4 repeat:HUGE_VALF]; 339 | [UIView animateWithDuration:0.4 animations:^{ 340 | [_item3 setFrame:_initialItem3Frame]; 341 | } completion:^(BOOL finished) { 342 | [_item3.layer removeAllAnimations]; 343 | }]; 344 | 345 | [self runSpinAnimationOnView:_item4 duration:3 rotations:4 repeat:HUGE_VALF]; 346 | [UIView animateWithDuration:0.4 animations:^{ 347 | [_item4 setFrame:_initialItem4Frame]; 348 | } completion:^(BOOL finished) { 349 | [_item4.layer removeAllAnimations]; 350 | }]; 351 | 352 | [self runSpinAnimationOnView:_item5 duration:3 rotations:4 repeat:HUGE_VALF]; 353 | [UIView animateWithDuration:0.4 animations:^{ 354 | [_item5 setFrame:_initialItem5Frame]; 355 | } completion:^(BOOL finished) { 356 | [_item5.layer removeAllAnimations]; 357 | }]; 358 | 359 | [self runSpinAnimationOnView:_item6 duration:3 rotations:4 repeat:HUGE_VALF]; 360 | [UIView animateWithDuration:0.4 animations:^{ 361 | _item6.frame = _initialItem6Frame; 362 | } completion:^(BOOL finished) { 363 | [_item6.layer removeAllAnimations]; 364 | [self removeFromDisplay]; 365 | }]; 366 | 367 | } 368 | 369 | - (void) removeFromDisplay 370 | { 371 | [_backgroundView removeFromSuperview]; 372 | [_item1 removeFromSuperview]; 373 | [_item2 removeFromSuperview]; 374 | [_item3 removeFromSuperview]; 375 | [_item4 removeFromSuperview]; 376 | [_item5 removeFromSuperview]; 377 | [_item6 removeFromSuperview]; 378 | } 379 | 380 | - (void) addToDisplay 381 | { 382 | [self.vc.view addSubview:_backgroundView]; 383 | [self.vc.view addSubview:_item1]; 384 | [self.vc.view addSubview:_item2]; 385 | [self.vc.view addSubview:_item3]; 386 | [self.vc.view addSubview:_item4]; 387 | [self.vc.view addSubview:_item5]; 388 | [self.vc.view addSubview:_item6]; 389 | } 390 | 391 | - (void) updateFramesAfterDeviceRotation 392 | { 393 | _initialBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2), (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 1, 1); 394 | _finalBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2)-80-20, (DEVICE_SIZE.height/2)-_centreOffSet_vertical-20, 210, 140); 395 | 396 | 397 | _finalItem1Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 398 | _initialItem1Frame = CGRectMake(-50, -50, 50, 50); 399 | 400 | 401 | _finalItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 402 | _initialItem2Frame = CGRectMake(80+60, -50, 50, 50); 403 | 404 | 405 | _finalItem3Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 406 | _initialItem3Frame = CGRectMake(DEVICE_SIZE.width+20, -50, 50, 50); 407 | 408 | 409 | _finalItem4Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 410 | _initialItem4Frame = CGRectMake(-50, DEVICE_SIZE.height+50-_centreOffSet_vertical, 50, 50); 411 | 412 | 413 | _finalItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 414 | _initialItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, DEVICE_SIZE.height+50, 50, 50); 415 | 416 | 417 | _finalItem6Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 418 | _initialItem6Frame = CGRectMake(DEVICE_SIZE.width+20, DEVICE_SIZE.height+50-_centreOffSet_vertical, 50, 50); 419 | 420 | 421 | [_backgroundView setFrame:_finalBackgroundFrame]; 422 | [_item1 setFrame:_finalItem1Frame]; 423 | [_item2 setFrame:_finalItem2Frame]; 424 | [_item3 setFrame:_finalItem3Frame]; 425 | [_item4 setFrame:_finalItem4Frame]; 426 | [_item5 setFrame:_finalItem5Frame]; 427 | [_item6 setFrame:_finalItem6Frame]; 428 | } 429 | 430 | 431 | #pragma mark - Setters and Customization 432 | 433 | - (void) setBackgroundBlurEnabled:(BOOL) enabled 434 | { 435 | if(enabled){ 436 | _backgroundView = _blurredBackgroundView; 437 | } 438 | else{ 439 | _backgroundView = _regularBackgroundView; 440 | } 441 | } 442 | 443 | 444 | - (void) setShowsBackgroundFrame:(BOOL) hasFrame 445 | { 446 | if(hasFrame){ 447 | _backgroundView.backgroundColor = self.backgroundColour; 448 | _backgroundView.tintColor = self.transparentTintColour; 449 | } 450 | else{ 451 | [self setBackgroundBlurEnabled:NO]; 452 | 453 | _backgroundView.backgroundColor = nil; 454 | _backgroundView.tintColor = nil; 455 | } 456 | } 457 | 458 | - (void) changeBackgroundColour:(UIColor *)backgroundColour 459 | { 460 | self.backgroundColour = backgroundColour; 461 | 462 | _regularBackgroundView.backgroundColor = self.backgroundColour; 463 | } 464 | 465 | - (void) changeTransparentTintColour:(UIColor *)transparentTintColour 466 | { 467 | self.transparentTintColour = transparentTintColour; 468 | 469 | _blurredBackgroundView.tintColor = self.transparentTintColour; 470 | } 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | #pragma mark - Helper Methods 479 | 480 | - (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat; 481 | { 482 | CABasicAnimation* rotationAnimation; 483 | rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 484 | rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ]; 485 | rotationAnimation.duration = duration; 486 | rotationAnimation.cumulative = YES; 487 | rotationAnimation.repeatCount = repeat; 488 | 489 | [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; 490 | } 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | @end 506 | -------------------------------------------------------------------------------- /OECentreMenu/OECentreMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenu.m 3 | // 4 | // Created by Odie Edo-Osagie on 09/07/2014. 5 | // Copyright (c) 2014 Odie Edo-Osagie. All rights reserved. 6 | // 7 | // Get the latest version from here: 8 | // 9 | // https://github.com/oduwa/OECentreMenu 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would be 22 | // appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not be 25 | // misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source distribution. 28 | // 29 | 30 | #import "OECentreMenu.h" 31 | #import "FXBlurView.h" 32 | #import "AppUtils.h" 33 | #import 34 | 35 | #define DEVICE_SIZE [[[[UIApplication sharedApplication] keyWindow] rootViewController].view convertRect:[[UIScreen mainScreen] bounds] fromView:nil].size 36 | 37 | #define COLOUR_PURPLE_STUDIO [AppUtils colorWithHexString:@"#8E44AD"]; 38 | #define COLOUR_PURPLE_REBECCAPURPLE [AppUtils colorWithHexString:@"#663399"]; 39 | #define COLOUR_PURPLE_HONEYFLOWER [AppUtils colorWithHexString:@"#674172"]; 40 | 41 | 42 | @implementation OECentreMenu 43 | 44 | 45 | #pragma mark - Initialization 46 | 47 | - (instancetype) init 48 | { 49 | self = [super init]; 50 | 51 | if(self){ 52 | _backgroundView = [[UIView alloc] init]; 53 | _initialBackgroundFrame = CGRectZero; 54 | _finalBackgroundFrame = CGRectZero; 55 | 56 | _item1 = [[UIButton alloc] init]; 57 | _initialItem1Frame = CGRectZero; 58 | _finalItem1Frame = CGRectZero; 59 | 60 | _item2 = [[UIButton alloc] init]; 61 | _initialItem2Frame = CGRectZero; 62 | _finalItem2Frame = CGRectZero; 63 | 64 | _item3 = [[UIButton alloc] init]; 65 | _initialItem3Frame = CGRectZero; 66 | _finalItem3Frame = CGRectZero; 67 | 68 | _item4 = [[UIButton alloc] init]; 69 | _initialItem4Frame = CGRectZero; 70 | _finalItem4Frame = CGRectZero; 71 | 72 | _item5 = [[UIButton alloc] init]; 73 | _initialItem5Frame = CGRectZero; 74 | _finalItem5Frame = CGRectZero; 75 | 76 | _item6 = [[UIButton alloc] init]; 77 | _initialItem6Frame = CGRectZero; 78 | _finalItem6Frame = CGRectZero; 79 | } 80 | 81 | return self; 82 | } 83 | 84 | 85 | - (id) initInViewController: (UIViewController *)vc withButtons:(NSArray *)buttons andVerticalOffset: (float)yValue 86 | { 87 | return [self initPrivatelyWithController:vc andButtons:buttons andOffSet:yValue]; 88 | } 89 | 90 | - (id) initInViewController: (UIViewController *)vc withButtons: (NSArray *)buttons thatHasTabBar: (BOOL) hasTabBar 91 | { 92 | int tabBarHeight; 93 | 94 | if(!hasTabBar){ 95 | tabBarHeight = 0; 96 | } 97 | else{ 98 | tabBarHeight = 49; 99 | } 100 | 101 | if([vc isKindOfClass:[UITableViewController class]]){ 102 | tabBarHeight += 70; 103 | } 104 | 105 | return [self initPrivatelyWithController:vc andButtons:buttons andOffSet:tabBarHeight]; 106 | } 107 | 108 | - (id) initPrivatelyWithController: (UIViewController *)vc andButtons: (NSArray *) buttons andOffSet: (float) yValue 109 | { 110 | self = [self init]; 111 | 112 | self.vc = vc; 113 | self.centreOffSet_vertical = yValue; 114 | self.backgroundColour = COLOUR_PURPLE_HONEYFLOWER; 115 | self.transparentTintColour = [UIColor cyanColor]; 116 | 117 | 118 | /* Background View */ 119 | _initialBackgroundFrame = CGRectMake(DEVICE_SIZE.width+20, (DEVICE_SIZE.height/2)-yValue, 10, 10); 120 | _finalBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2)-80-20, (DEVICE_SIZE.height/2)-yValue-20, 210, 140); 121 | _backgroundView = [[FXBlurView alloc] init]; 122 | [_backgroundView setFrame:_initialBackgroundFrame]; 123 | _backgroundView.layer.cornerRadius = 5.0f; 124 | _backgroundView.tintColor = self.transparentTintColour; 125 | [vc.view addSubview:_backgroundView]; 126 | 127 | _regularBackgroundView = [[UIView alloc] initWithFrame:_initialBackgroundFrame]; 128 | _regularBackgroundView.layer.cornerRadius = 5.0f; 129 | _regularBackgroundView.backgroundColor = self.backgroundColour; 130 | [vc.view addSubview:_regularBackgroundView]; 131 | 132 | _blurredBackgroundView = _backgroundView; 133 | 134 | /* top left */ 135 | _finalItem1Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-yValue, 50, 50); 136 | _initialItem1Frame = CGRectMake(-50, -50, 50, 50); 137 | if([buttons count] < 1){ 138 | _item1 = [[UIButton alloc] init]; 139 | _item1.backgroundColor = [UIColor redColor]; 140 | [_item1 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 141 | [_item1 addTarget:self 142 | action:@selector(buttonPressed) 143 | forControlEvents:UIControlEventTouchUpInside]; 144 | } 145 | else{ 146 | _item1 = buttons[0]; 147 | } 148 | [_item1 setFrame:_initialItem1Frame]; 149 | _item1.layer.cornerRadius = 25.0; 150 | _item1.clipsToBounds = YES; 151 | [vc.view addSubview:_item1]; 152 | 153 | /* top center */ 154 | _finalItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-yValue, 50, 50); 155 | _initialItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, -50, 50, 50); 156 | if([buttons count] < 2){ 157 | _item2 = [[UIButton alloc] init]; 158 | _item2.backgroundColor = [UIColor yellowColor]; 159 | [_item2 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 160 | [_item2 addTarget:self 161 | action:@selector(buttonPressed) 162 | forControlEvents:UIControlEventTouchUpInside]; 163 | } 164 | else{ 165 | _item2 = buttons[1]; 166 | } 167 | [_item2 setFrame:_initialItem2Frame]; 168 | _item2.layer.cornerRadius = 25.0; 169 | _item2.clipsToBounds = YES; 170 | [vc.view addSubview:_item2]; 171 | 172 | /* top right */ 173 | _finalItem3Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-yValue, 50, 50); 174 | _initialItem3Frame = CGRectMake(DEVICE_SIZE.width+20, -50, 50, 50); 175 | if([buttons count] < 3){ 176 | _item3 = [[UIButton alloc] init]; 177 | _item3.backgroundColor = [UIColor blueColor]; 178 | [_item3 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 179 | [_item3 addTarget:self 180 | action:@selector(buttonPressed) 181 | forControlEvents:UIControlEventTouchUpInside]; 182 | } 183 | else{ 184 | _item3 = buttons[2]; 185 | } 186 | [_item3 setFrame:_initialItem3Frame]; 187 | _item3.layer.cornerRadius = 25.0; 188 | _item3.clipsToBounds = YES; 189 | [vc.view addSubview:_item3]; 190 | 191 | /* bottom left */ 192 | _finalItem4Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 193 | _initialItem4Frame = CGRectMake(-50, DEVICE_SIZE.height+50-yValue, 50, 50); 194 | if([buttons count] < 4){ 195 | _item4 = [[UIButton alloc] init]; 196 | _item4.backgroundColor = [UIColor orangeColor]; 197 | [_item4 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 198 | [_item4 addTarget:self 199 | action:@selector(buttonPressed) 200 | forControlEvents:UIControlEventTouchUpInside]; 201 | } 202 | else{ 203 | _item4 = buttons[3]; 204 | } 205 | [_item4 setFrame:_initialItem4Frame]; 206 | _item4.layer.cornerRadius = 25.0; 207 | _item4.clipsToBounds = YES; 208 | [vc.view addSubview:_item4]; 209 | 210 | /* bottom center */ 211 | _finalItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 212 | _initialItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, DEVICE_SIZE.height+50, 50, 50); 213 | if([buttons count] < 5){ 214 | _item5 = [[UIButton alloc] init]; 215 | _item5.backgroundColor = [UIColor cyanColor]; 216 | [_item5 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 217 | [_item5 addTarget:self 218 | action:@selector(buttonPressed) 219 | forControlEvents:UIControlEventTouchUpInside]; 220 | } 221 | else{ 222 | _item5 = buttons[4]; 223 | } 224 | [_item5 setFrame:_initialItem5Frame]; 225 | _item5.layer.cornerRadius = 25.0; 226 | _item5.clipsToBounds = YES; 227 | [vc.view addSubview:_item5]; 228 | 229 | 230 | /* bottom right */ 231 | _finalItem6Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 232 | _initialItem6Frame = CGRectMake(DEVICE_SIZE.width+20, DEVICE_SIZE.height+50-yValue, 50, 50); 233 | if([buttons count] < 6){ 234 | _item6 = [[UIButton alloc] init]; 235 | _item6.backgroundColor = [UIColor magentaColor]; 236 | [_item6 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 237 | [_item6 addTarget:self 238 | action:@selector(buttonPressed) 239 | forControlEvents:UIControlEventTouchUpInside]; 240 | } 241 | else{ 242 | _item6 = buttons[5]; 243 | } 244 | [_item6 setFrame:_initialItem6Frame]; 245 | _item6.layer.cornerRadius = 25.0; 246 | _item6.clipsToBounds = YES; 247 | [vc.view addSubview:_item6]; 248 | 249 | [self hide]; 250 | 251 | return self; 252 | } 253 | 254 | #pragma mark - Presentation 255 | 256 | - (void) show 257 | { 258 | 259 | if(!self){ 260 | [NSException raise:@"UninitializedMenuException" format:@"Attempting to show menu without first initializing one."]; 261 | } 262 | 263 | [self addToDisplay]; 264 | 265 | [UIView animateWithDuration:0.2 animations:^{ 266 | _backgroundView.frame = _finalBackgroundFrame; 267 | }]; 268 | 269 | [self runSpinAnimationOnView:_item1 duration:3 rotations:4 repeat:HUGE_VALF]; 270 | [UIView animateWithDuration:0.4 animations:^{ 271 | [_item1 setFrame:_finalItem1Frame]; 272 | } completion:^(BOOL finished) { 273 | [_item1.layer removeAllAnimations]; 274 | }]; 275 | 276 | [self runSpinAnimationOnView:_item2 duration:3 rotations:4 repeat:HUGE_VALF]; 277 | [UIView animateWithDuration:0.4 animations:^{ 278 | [_item2 setFrame:_finalItem2Frame]; 279 | } completion:^(BOOL finished) { 280 | [_item2.layer removeAllAnimations]; 281 | }]; 282 | 283 | [self runSpinAnimationOnView:_item3 duration:3 rotations:4 repeat:HUGE_VALF]; 284 | [UIView animateWithDuration:0.4 animations:^{ 285 | [_item3 setFrame:_finalItem3Frame]; 286 | } completion:^(BOOL finished) { 287 | [_item3.layer removeAllAnimations]; 288 | }]; 289 | 290 | [self runSpinAnimationOnView:_item4 duration:3 rotations:4 repeat:HUGE_VALF]; 291 | [UIView animateWithDuration:0.4 animations:^{ 292 | [_item4 setFrame:_finalItem4Frame]; 293 | } completion:^(BOOL finished) { 294 | [_item4.layer removeAllAnimations]; 295 | }]; 296 | 297 | [self runSpinAnimationOnView:_item5 duration:3 rotations:4 repeat:HUGE_VALF]; 298 | [UIView animateWithDuration:0.4 animations:^{ 299 | [_item5 setFrame:_finalItem5Frame]; 300 | } completion:^(BOOL finished) { 301 | [_item5.layer removeAllAnimations]; 302 | }]; 303 | 304 | [self runSpinAnimationOnView:_item6 duration:3 rotations:4 repeat:HUGE_VALF]; 305 | [UIView animateWithDuration:0.4 animations:^{ 306 | _item6.frame = _finalItem6Frame; 307 | } completion:^(BOOL finished) { 308 | [_item6.layer removeAllAnimations]; 309 | }]; 310 | 311 | } 312 | 313 | 314 | - (void) hide 315 | { 316 | 317 | if(!self){ 318 | [NSException raise:@"UninitializedMenuException" format:@"Attempting to hide menu without first initializing one."]; 319 | } 320 | 321 | [UIView animateWithDuration:0.2 animations:^{ 322 | _backgroundView.frame = _initialBackgroundFrame; 323 | }]; 324 | 325 | [self runSpinAnimationOnView:_item1 duration:3 rotations:4 repeat:HUGE_VALF]; 326 | [UIView animateWithDuration:0.4 animations:^{ 327 | [_item1 setFrame:_initialItem1Frame]; 328 | } completion:^(BOOL finished) { 329 | [_item1.layer removeAllAnimations]; 330 | }]; 331 | 332 | [self runSpinAnimationOnView:_item2 duration:3 rotations:4 repeat:HUGE_VALF]; 333 | [UIView animateWithDuration:0.4 animations:^{ 334 | [_item2 setFrame:_initialItem2Frame]; 335 | } completion:^(BOOL finished) { 336 | [_item2.layer removeAllAnimations]; 337 | }]; 338 | 339 | [self runSpinAnimationOnView:_item3 duration:3 rotations:4 repeat:HUGE_VALF]; 340 | [UIView animateWithDuration:0.4 animations:^{ 341 | [_item3 setFrame:_initialItem3Frame]; 342 | } completion:^(BOOL finished) { 343 | [_item3.layer removeAllAnimations]; 344 | }]; 345 | 346 | [self runSpinAnimationOnView:_item4 duration:3 rotations:4 repeat:HUGE_VALF]; 347 | [UIView animateWithDuration:0.4 animations:^{ 348 | [_item4 setFrame:_initialItem4Frame]; 349 | } completion:^(BOOL finished) { 350 | [_item4.layer removeAllAnimations]; 351 | }]; 352 | 353 | [self runSpinAnimationOnView:_item5 duration:3 rotations:4 repeat:HUGE_VALF]; 354 | [UIView animateWithDuration:0.4 animations:^{ 355 | [_item5 setFrame:_initialItem5Frame]; 356 | } completion:^(BOOL finished) { 357 | [_item5.layer removeAllAnimations]; 358 | }]; 359 | 360 | [self runSpinAnimationOnView:_item6 duration:3 rotations:4 repeat:HUGE_VALF]; 361 | [UIView animateWithDuration:0.4 animations:^{ 362 | _item6.frame = _initialItem6Frame; 363 | } completion:^(BOOL finished) { 364 | [_item6.layer removeAllAnimations]; 365 | [self removeFromDisplay]; 366 | }]; 367 | 368 | } 369 | 370 | - (void) removeFromDisplay 371 | { 372 | [_backgroundView removeFromSuperview]; 373 | [_item1 removeFromSuperview]; 374 | [_item2 removeFromSuperview]; 375 | [_item3 removeFromSuperview]; 376 | [_item4 removeFromSuperview]; 377 | [_item5 removeFromSuperview]; 378 | [_item6 removeFromSuperview]; 379 | } 380 | 381 | - (void) addToDisplay 382 | { 383 | [self.vc.view addSubview:_backgroundView]; 384 | [self.vc.view addSubview:_item1]; 385 | [self.vc.view addSubview:_item2]; 386 | [self.vc.view addSubview:_item3]; 387 | [self.vc.view addSubview:_item4]; 388 | [self.vc.view addSubview:_item5]; 389 | [self.vc.view addSubview:_item6]; 390 | } 391 | 392 | - (void) updateFramesAfterDeviceRotation 393 | { 394 | _initialBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2), (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 1, 1); 395 | _finalBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2)-80-20, (DEVICE_SIZE.height/2)-_centreOffSet_vertical-20, 210, 140); 396 | 397 | 398 | _finalItem1Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 399 | _initialItem1Frame = CGRectMake(-50, -50, 50, 50); 400 | 401 | 402 | _finalItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 403 | _initialItem2Frame = CGRectMake(80+60, -50, 50, 50); 404 | 405 | 406 | _finalItem3Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 407 | _initialItem3Frame = CGRectMake(DEVICE_SIZE.width+20, -50, 50, 50); 408 | 409 | 410 | _finalItem4Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 411 | _initialItem4Frame = CGRectMake(-50, DEVICE_SIZE.height+50-_centreOffSet_vertical, 50, 50); 412 | 413 | 414 | _finalItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 415 | _initialItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, DEVICE_SIZE.height+50, 50, 50); 416 | 417 | 418 | _finalItem6Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 419 | _initialItem6Frame = CGRectMake(DEVICE_SIZE.width+20, DEVICE_SIZE.height+50-_centreOffSet_vertical, 50, 50); 420 | 421 | 422 | [_backgroundView setFrame:_finalBackgroundFrame]; 423 | [_item1 setFrame:_finalItem1Frame]; 424 | [_item2 setFrame:_finalItem2Frame]; 425 | [_item3 setFrame:_finalItem3Frame]; 426 | [_item4 setFrame:_finalItem4Frame]; 427 | [_item5 setFrame:_finalItem5Frame]; 428 | [_item6 setFrame:_finalItem6Frame]; 429 | } 430 | 431 | 432 | #pragma mark - Setters and Customization 433 | 434 | - (void) setBackgroundBlurEnabled:(BOOL) enabled 435 | { 436 | if(enabled){ 437 | _backgroundView = _blurredBackgroundView; 438 | } 439 | else{ 440 | _backgroundView = _regularBackgroundView; 441 | } 442 | } 443 | 444 | 445 | - (void) setShowsBackgroundFrame:(BOOL) hasFrame 446 | { 447 | if(hasFrame){ 448 | _backgroundView.backgroundColor = self.backgroundColour; 449 | _backgroundView.tintColor = self.transparentTintColour; 450 | } 451 | else{ 452 | [self setBackgroundBlurEnabled:NO]; 453 | 454 | _backgroundView.backgroundColor = nil; 455 | _backgroundView.tintColor = nil; 456 | } 457 | } 458 | 459 | - (void) changeBackgroundColour:(UIColor *)backgroundColour 460 | { 461 | self.backgroundColour = backgroundColour; 462 | 463 | _regularBackgroundView.backgroundColor = self.backgroundColour; 464 | } 465 | 466 | - (void) changeTransparentTintColour:(UIColor *)transparentTintColour 467 | { 468 | self.transparentTintColour = transparentTintColour; 469 | 470 | _blurredBackgroundView.tintColor = self.transparentTintColour; 471 | } 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | #pragma mark - Helper Methods 480 | 481 | - (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat; 482 | { 483 | CABasicAnimation* rotationAnimation; 484 | rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 485 | rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ]; 486 | rotationAnimation.duration = duration; 487 | rotationAnimation.cumulative = YES; 488 | rotationAnimation.repeatCount = repeat; 489 | 490 | [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; 491 | } 492 | 493 | 494 | 495 | #pragma mark - Selectors 496 | 497 | - (void) buttonPressed 498 | { 499 | NSLog(@"OECentreMenu: BUTTON PRESSED!!!"); 500 | } 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | @end 513 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenu/OECentreMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // OECentreMenu.m 3 | // 4 | // Created by Odie Edo-Osagie on 09/07/2014. 5 | // Copyright (c) 2014 Odie Edo-Osagie. All rights reserved. 6 | // 7 | // Get the latest version from here: 8 | // 9 | // https://github.com/oduwa/OECentreMenu 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would be 22 | // appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not be 25 | // misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source distribution. 28 | // 29 | 30 | #import "OECentreMenu.h" 31 | #import "FXBlurView.h" 32 | #import "AppUtils.h" 33 | #import 34 | 35 | #define DEVICE_SIZE [[[[UIApplication sharedApplication] keyWindow] rootViewController].view convertRect:[[UIScreen mainScreen] bounds] fromView:nil].size 36 | 37 | #define COLOUR_PURPLE_STUDIO [AppUtils colorWithHexString:@"#8E44AD"]; 38 | #define COLOUR_PURPLE_REBECCAPURPLE [AppUtils colorWithHexString:@"#663399"]; 39 | #define COLOUR_PURPLE_HONEYFLOWER [AppUtils colorWithHexString:@"#674172"]; 40 | 41 | 42 | @implementation OECentreMenu 43 | 44 | 45 | #pragma mark - Initialization 46 | 47 | - (instancetype) init 48 | { 49 | self = [super init]; 50 | 51 | if(self){ 52 | _backgroundView = [[UIView alloc] init]; 53 | _initialBackgroundFrame = CGRectZero; 54 | _finalBackgroundFrame = CGRectZero; 55 | 56 | _item1 = [[UIButton alloc] init]; 57 | _initialItem1Frame = CGRectZero; 58 | _finalItem1Frame = CGRectZero; 59 | 60 | _item2 = [[UIButton alloc] init]; 61 | _initialItem2Frame = CGRectZero; 62 | _finalItem2Frame = CGRectZero; 63 | 64 | _item3 = [[UIButton alloc] init]; 65 | _initialItem3Frame = CGRectZero; 66 | _finalItem3Frame = CGRectZero; 67 | 68 | _item4 = [[UIButton alloc] init]; 69 | _initialItem4Frame = CGRectZero; 70 | _finalItem4Frame = CGRectZero; 71 | 72 | _item5 = [[UIButton alloc] init]; 73 | _initialItem5Frame = CGRectZero; 74 | _finalItem5Frame = CGRectZero; 75 | 76 | _item6 = [[UIButton alloc] init]; 77 | _initialItem6Frame = CGRectZero; 78 | _finalItem6Frame = CGRectZero; 79 | } 80 | 81 | return self; 82 | } 83 | 84 | 85 | - (id) initInViewController: (UIViewController *)vc withButtons:(NSArray *)buttons andVerticalOffset: (float)yValue 86 | { 87 | return [self initPrivatelyWithController:vc andButtons:buttons andOffSet:yValue]; 88 | } 89 | 90 | - (id) initInViewController: (UIViewController *)vc withButtons: (NSArray *)buttons thatHasTabBar: (BOOL) hasTabBar 91 | { 92 | int tabBarHeight; 93 | 94 | if(!hasTabBar){ 95 | tabBarHeight = 0; 96 | } 97 | else{ 98 | tabBarHeight = 49; 99 | } 100 | 101 | if([vc isKindOfClass:[UITableViewController class]]){ 102 | tabBarHeight += 70; 103 | } 104 | 105 | return [self initPrivatelyWithController:vc andButtons:buttons andOffSet:tabBarHeight]; 106 | } 107 | 108 | - (id) initPrivatelyWithController: (UIViewController *)vc andButtons: (NSArray *) buttons andOffSet: (float) yValue 109 | { 110 | self = [self init]; 111 | 112 | self.vc = vc; 113 | self.centreOffSet_vertical = yValue; 114 | self.backgroundColour = COLOUR_PURPLE_HONEYFLOWER; 115 | self.transparentTintColour = [UIColor cyanColor]; 116 | 117 | 118 | /* Background View */ 119 | _initialBackgroundFrame = CGRectMake(DEVICE_SIZE.width+20, (DEVICE_SIZE.height/2)-yValue, 10, 10); 120 | _finalBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2)-80-20, (DEVICE_SIZE.height/2)-yValue-20, 210, 140); 121 | _backgroundView = [[FXBlurView alloc] init]; 122 | [_backgroundView setFrame:_initialBackgroundFrame]; 123 | _backgroundView.layer.cornerRadius = 5.0f; 124 | _backgroundView.tintColor = self.transparentTintColour; 125 | [vc.view addSubview:_backgroundView]; 126 | 127 | _regularBackgroundView = [[UIView alloc] initWithFrame:_initialBackgroundFrame]; 128 | _regularBackgroundView.layer.cornerRadius = 5.0f; 129 | _regularBackgroundView.backgroundColor = self.backgroundColour; 130 | [vc.view addSubview:_regularBackgroundView]; 131 | 132 | _blurredBackgroundView = _backgroundView; 133 | 134 | /* top left */ 135 | _finalItem1Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-yValue, 50, 50); 136 | _initialItem1Frame = CGRectMake(-50, -50, 50, 50); 137 | if([buttons count] < 1){ 138 | _item1 = [[UIButton alloc] init]; 139 | _item1.backgroundColor = [UIColor redColor]; 140 | [_item1 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 141 | [_item1 addTarget:self 142 | action:@selector(buttonPressed) 143 | forControlEvents:UIControlEventTouchUpInside]; 144 | } 145 | else{ 146 | _item1 = buttons[0]; 147 | } 148 | [_item1 setFrame:_initialItem1Frame]; 149 | _item1.layer.cornerRadius = 25.0; 150 | _item1.clipsToBounds = YES; 151 | [vc.view addSubview:_item1]; 152 | 153 | /* top center */ 154 | _finalItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-yValue, 50, 50); 155 | _initialItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, -50, 50, 50); 156 | if([buttons count] < 2){ 157 | _item2 = [[UIButton alloc] init]; 158 | _item2.backgroundColor = [UIColor yellowColor]; 159 | [_item2 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 160 | [_item2 addTarget:self 161 | action:@selector(buttonPressed) 162 | forControlEvents:UIControlEventTouchUpInside]; 163 | } 164 | else{ 165 | _item2 = buttons[1]; 166 | } 167 | [_item2 setFrame:_initialItem2Frame]; 168 | _item2.layer.cornerRadius = 25.0; 169 | _item2.clipsToBounds = YES; 170 | [vc.view addSubview:_item2]; 171 | 172 | /* top right */ 173 | _finalItem3Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-yValue, 50, 50); 174 | _initialItem3Frame = CGRectMake(DEVICE_SIZE.width+20, -50, 50, 50); 175 | if([buttons count] < 3){ 176 | _item3 = [[UIButton alloc] init]; 177 | _item3.backgroundColor = [UIColor blueColor]; 178 | [_item3 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 179 | [_item3 addTarget:self 180 | action:@selector(buttonPressed) 181 | forControlEvents:UIControlEventTouchUpInside]; 182 | } 183 | else{ 184 | _item3 = buttons[2]; 185 | } 186 | [_item3 setFrame:_initialItem3Frame]; 187 | _item3.layer.cornerRadius = 25.0; 188 | _item3.clipsToBounds = YES; 189 | [vc.view addSubview:_item3]; 190 | 191 | /* bottom left */ 192 | _finalItem4Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 193 | _initialItem4Frame = CGRectMake(-50, DEVICE_SIZE.height+50-yValue, 50, 50); 194 | if([buttons count] < 4){ 195 | _item4 = [[UIButton alloc] init]; 196 | _item4.backgroundColor = [UIColor orangeColor]; 197 | [_item4 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 198 | [_item4 addTarget:self 199 | action:@selector(buttonPressed) 200 | forControlEvents:UIControlEventTouchUpInside]; 201 | } 202 | else{ 203 | _item4 = buttons[3]; 204 | } 205 | [_item4 setFrame:_initialItem4Frame]; 206 | _item4.layer.cornerRadius = 25.0; 207 | _item4.clipsToBounds = YES; 208 | [vc.view addSubview:_item4]; 209 | 210 | /* bottom center */ 211 | _finalItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 212 | _initialItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, DEVICE_SIZE.height+50, 50, 50); 213 | if([buttons count] < 5){ 214 | _item5 = [[UIButton alloc] init]; 215 | _item5.backgroundColor = [UIColor cyanColor]; 216 | [_item5 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 217 | [_item5 addTarget:self 218 | action:@selector(buttonPressed) 219 | forControlEvents:UIControlEventTouchUpInside]; 220 | } 221 | else{ 222 | _item5 = buttons[4]; 223 | } 224 | [_item5 setFrame:_initialItem5Frame]; 225 | _item5.layer.cornerRadius = 25.0; 226 | _item5.clipsToBounds = YES; 227 | [vc.view addSubview:_item5]; 228 | 229 | 230 | /* bottom right */ 231 | _finalItem6Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-yValue+50, 50, 50); 232 | _initialItem6Frame = CGRectMake(DEVICE_SIZE.width+20, DEVICE_SIZE.height+50-yValue, 50, 50); 233 | if([buttons count] < 6){ 234 | _item6 = [[UIButton alloc] init]; 235 | _item6.backgroundColor = [UIColor magentaColor]; 236 | [_item6 setBackgroundImage:[UIImage imageNamed:@"quaver.png"] forState:UIControlStateNormal]; 237 | [_item6 addTarget:self 238 | action:@selector(buttonPressed) 239 | forControlEvents:UIControlEventTouchUpInside]; 240 | } 241 | else{ 242 | _item6 = buttons[5]; 243 | } 244 | [_item6 setFrame:_initialItem6Frame]; 245 | _item6.layer.cornerRadius = 25.0; 246 | _item6.clipsToBounds = YES; 247 | [vc.view addSubview:_item6]; 248 | 249 | [self hide]; 250 | 251 | return self; 252 | } 253 | 254 | #pragma mark - Presentation 255 | 256 | - (void) show 257 | { 258 | 259 | if(!self){ 260 | [NSException raise:@"UninitializedMenuException" format:@"Attempting to show menu without first initializing one."]; 261 | } 262 | 263 | [self addToDisplay]; 264 | 265 | [UIView animateWithDuration:0.2 animations:^{ 266 | _backgroundView.frame = _finalBackgroundFrame; 267 | }]; 268 | 269 | [self runSpinAnimationOnView:_item1 duration:3 rotations:4 repeat:HUGE_VALF]; 270 | [UIView animateWithDuration:0.4 animations:^{ 271 | [_item1 setFrame:_finalItem1Frame]; 272 | } completion:^(BOOL finished) { 273 | [_item1.layer removeAllAnimations]; 274 | }]; 275 | 276 | [self runSpinAnimationOnView:_item2 duration:3 rotations:4 repeat:HUGE_VALF]; 277 | [UIView animateWithDuration:0.4 animations:^{ 278 | [_item2 setFrame:_finalItem2Frame]; 279 | } completion:^(BOOL finished) { 280 | [_item2.layer removeAllAnimations]; 281 | }]; 282 | 283 | [self runSpinAnimationOnView:_item3 duration:3 rotations:4 repeat:HUGE_VALF]; 284 | [UIView animateWithDuration:0.4 animations:^{ 285 | [_item3 setFrame:_finalItem3Frame]; 286 | } completion:^(BOOL finished) { 287 | [_item3.layer removeAllAnimations]; 288 | }]; 289 | 290 | [self runSpinAnimationOnView:_item4 duration:3 rotations:4 repeat:HUGE_VALF]; 291 | [UIView animateWithDuration:0.4 animations:^{ 292 | [_item4 setFrame:_finalItem4Frame]; 293 | } completion:^(BOOL finished) { 294 | [_item4.layer removeAllAnimations]; 295 | }]; 296 | 297 | [self runSpinAnimationOnView:_item5 duration:3 rotations:4 repeat:HUGE_VALF]; 298 | [UIView animateWithDuration:0.4 animations:^{ 299 | [_item5 setFrame:_finalItem5Frame]; 300 | } completion:^(BOOL finished) { 301 | [_item5.layer removeAllAnimations]; 302 | }]; 303 | 304 | [self runSpinAnimationOnView:_item6 duration:3 rotations:4 repeat:HUGE_VALF]; 305 | [UIView animateWithDuration:0.4 animations:^{ 306 | _item6.frame = _finalItem6Frame; 307 | } completion:^(BOOL finished) { 308 | [_item6.layer removeAllAnimations]; 309 | }]; 310 | 311 | } 312 | 313 | 314 | - (void) hide 315 | { 316 | 317 | if(!self){ 318 | [NSException raise:@"UninitializedMenuException" format:@"Attempting to hide menu without first initializing one."]; 319 | } 320 | 321 | [UIView animateWithDuration:0.2 animations:^{ 322 | _backgroundView.frame = _initialBackgroundFrame; 323 | }]; 324 | 325 | [self runSpinAnimationOnView:_item1 duration:3 rotations:4 repeat:HUGE_VALF]; 326 | [UIView animateWithDuration:0.4 animations:^{ 327 | [_item1 setFrame:_initialItem1Frame]; 328 | } completion:^(BOOL finished) { 329 | [_item1.layer removeAllAnimations]; 330 | }]; 331 | 332 | [self runSpinAnimationOnView:_item2 duration:3 rotations:4 repeat:HUGE_VALF]; 333 | [UIView animateWithDuration:0.4 animations:^{ 334 | [_item2 setFrame:_initialItem2Frame]; 335 | } completion:^(BOOL finished) { 336 | [_item2.layer removeAllAnimations]; 337 | }]; 338 | 339 | [self runSpinAnimationOnView:_item3 duration:3 rotations:4 repeat:HUGE_VALF]; 340 | [UIView animateWithDuration:0.4 animations:^{ 341 | [_item3 setFrame:_initialItem3Frame]; 342 | } completion:^(BOOL finished) { 343 | [_item3.layer removeAllAnimations]; 344 | }]; 345 | 346 | [self runSpinAnimationOnView:_item4 duration:3 rotations:4 repeat:HUGE_VALF]; 347 | [UIView animateWithDuration:0.4 animations:^{ 348 | [_item4 setFrame:_initialItem4Frame]; 349 | } completion:^(BOOL finished) { 350 | [_item4.layer removeAllAnimations]; 351 | }]; 352 | 353 | [self runSpinAnimationOnView:_item5 duration:3 rotations:4 repeat:HUGE_VALF]; 354 | [UIView animateWithDuration:0.4 animations:^{ 355 | [_item5 setFrame:_initialItem5Frame]; 356 | } completion:^(BOOL finished) { 357 | [_item5.layer removeAllAnimations]; 358 | }]; 359 | 360 | [self runSpinAnimationOnView:_item6 duration:3 rotations:4 repeat:HUGE_VALF]; 361 | [UIView animateWithDuration:0.4 animations:^{ 362 | _item6.frame = _initialItem6Frame; 363 | } completion:^(BOOL finished) { 364 | [_item6.layer removeAllAnimations]; 365 | [self removeFromDisplay]; 366 | }]; 367 | 368 | } 369 | 370 | - (void) removeFromDisplay 371 | { 372 | [_backgroundView removeFromSuperview]; 373 | [_item1 removeFromSuperview]; 374 | [_item2 removeFromSuperview]; 375 | [_item3 removeFromSuperview]; 376 | [_item4 removeFromSuperview]; 377 | [_item5 removeFromSuperview]; 378 | [_item6 removeFromSuperview]; 379 | } 380 | 381 | - (void) addToDisplay 382 | { 383 | [self.vc.view addSubview:_backgroundView]; 384 | [self.vc.view addSubview:_item1]; 385 | [self.vc.view addSubview:_item2]; 386 | [self.vc.view addSubview:_item3]; 387 | [self.vc.view addSubview:_item4]; 388 | [self.vc.view addSubview:_item5]; 389 | [self.vc.view addSubview:_item6]; 390 | } 391 | 392 | - (void) updateFramesAfterDeviceRotation 393 | { 394 | _initialBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2), (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 1, 1); 395 | _finalBackgroundFrame = CGRectMake((DEVICE_SIZE.width/2)-80-20, (DEVICE_SIZE.height/2)-_centreOffSet_vertical-20, 210, 140); 396 | 397 | 398 | _finalItem1Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 399 | _initialItem1Frame = CGRectMake(-50, -50, 50, 50); 400 | 401 | 402 | _finalItem2Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 403 | _initialItem2Frame = CGRectMake(80+60, -50, 50, 50); 404 | 405 | 406 | _finalItem3Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-_centreOffSet_vertical, 50, 50); 407 | _initialItem3Frame = CGRectMake(DEVICE_SIZE.width+20, -50, 50, 50); 408 | 409 | 410 | _finalItem4Frame = CGRectMake((DEVICE_SIZE.width/2)-80, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 411 | _initialItem4Frame = CGRectMake(-50, DEVICE_SIZE.height+50-_centreOffSet_vertical, 50, 50); 412 | 413 | 414 | _finalItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 415 | _initialItem5Frame = CGRectMake((DEVICE_SIZE.width/2)-80+60, DEVICE_SIZE.height+50, 50, 50); 416 | 417 | 418 | _finalItem6Frame = CGRectMake((DEVICE_SIZE.width/2)-80+120, (DEVICE_SIZE.height/2)-_centreOffSet_vertical+50, 50, 50); 419 | _initialItem6Frame = CGRectMake(DEVICE_SIZE.width+20, DEVICE_SIZE.height+50-_centreOffSet_vertical, 50, 50); 420 | 421 | 422 | [_backgroundView setFrame:_finalBackgroundFrame]; 423 | [_item1 setFrame:_finalItem1Frame]; 424 | [_item2 setFrame:_finalItem2Frame]; 425 | [_item3 setFrame:_finalItem3Frame]; 426 | [_item4 setFrame:_finalItem4Frame]; 427 | [_item5 setFrame:_finalItem5Frame]; 428 | [_item6 setFrame:_finalItem6Frame]; 429 | } 430 | 431 | 432 | #pragma mark - Setters and Customization 433 | 434 | - (void) setBackgroundBlurEnabled:(BOOL) enabled 435 | { 436 | if(enabled){ 437 | _backgroundView = _blurredBackgroundView; 438 | } 439 | else{ 440 | _backgroundView = _regularBackgroundView; 441 | } 442 | } 443 | 444 | 445 | - (void) setShowsBackgroundFrame:(BOOL) hasFrame 446 | { 447 | if(hasFrame){ 448 | _backgroundView.backgroundColor = self.backgroundColour; 449 | _backgroundView.tintColor = self.transparentTintColour; 450 | } 451 | else{ 452 | [self setBackgroundBlurEnabled:NO]; 453 | 454 | _backgroundView.backgroundColor = nil; 455 | _backgroundView.tintColor = nil; 456 | } 457 | } 458 | 459 | - (void) changeBackgroundColour:(UIColor *)backgroundColour 460 | { 461 | self.backgroundColour = backgroundColour; 462 | 463 | _regularBackgroundView.backgroundColor = self.backgroundColour; 464 | } 465 | 466 | - (void) changeTransparentTintColour:(UIColor *)transparentTintColour 467 | { 468 | self.transparentTintColour = transparentTintColour; 469 | 470 | _blurredBackgroundView.tintColor = self.transparentTintColour; 471 | } 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | #pragma mark - Helper Methods 480 | 481 | - (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat; 482 | { 483 | CABasicAnimation* rotationAnimation; 484 | rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 485 | rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ]; 486 | rotationAnimation.duration = duration; 487 | rotationAnimation.cumulative = YES; 488 | rotationAnimation.repeatCount = repeat; 489 | 490 | [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; 491 | } 492 | 493 | 494 | 495 | #pragma mark - Selectors 496 | 497 | - (void) buttonPressed 498 | { 499 | NSLog(@"OECentreMenu: BUTTON PRESSED!!!"); 500 | } 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | @end 513 | -------------------------------------------------------------------------------- /OECentreMenu/Supporting/FXBlurView/FXBlurView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FXBlurView.m 3 | // 4 | // Version 1.6.1 5 | // 6 | // Created by Nick Lockwood on 25/08/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FXBlurView 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import "FXBlurView.h" 35 | #import 36 | #import 37 | #import 38 | 39 | 40 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 41 | #pragma GCC diagnostic ignored "-Wdirect-ivar-access" 42 | #pragma GCC diagnostic ignored "-Wgnu" 43 | 44 | 45 | #import 46 | #if !__has_feature(objc_arc) 47 | #error This class requires automatic reference counting 48 | #endif 49 | 50 | 51 | @implementation UIImage (FXBlurView) 52 | 53 | - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor 54 | { 55 | //image must be nonzero size 56 | if (floorf(self.size.width) * floorf(self.size.height) <= 0.0f) return self; 57 | 58 | //boxsize must be an odd integer 59 | uint32_t boxSize = (uint32_t)(radius * self.scale); 60 | if (boxSize % 2 == 0) boxSize ++; 61 | 62 | //create image buffers 63 | CGImageRef imageRef = self.CGImage; 64 | vImage_Buffer buffer1, buffer2; 65 | buffer1.width = buffer2.width = CGImageGetWidth(imageRef); 66 | buffer1.height = buffer2.height = CGImageGetHeight(imageRef); 67 | buffer1.rowBytes = buffer2.rowBytes = CGImageGetBytesPerRow(imageRef); 68 | size_t bytes = buffer1.rowBytes * buffer1.height; 69 | buffer1.data = malloc(bytes); 70 | buffer2.data = malloc(bytes); 71 | 72 | //create temp buffer 73 | void *tempBuffer = malloc((size_t)vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, NULL, 0, 0, boxSize, boxSize, 74 | NULL, kvImageEdgeExtend + kvImageGetTempBufferSize)); 75 | 76 | //copy image data 77 | CFDataRef dataSource = CGDataProviderCopyData(CGImageGetDataProvider(imageRef)); 78 | memcpy(buffer1.data, CFDataGetBytePtr(dataSource), bytes); 79 | CFRelease(dataSource); 80 | 81 | for (NSUInteger i = 0; i < iterations; i++) 82 | { 83 | //perform blur 84 | vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, tempBuffer, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend); 85 | 86 | //swap buffers 87 | void *temp = buffer1.data; 88 | buffer1.data = buffer2.data; 89 | buffer2.data = temp; 90 | } 91 | 92 | //free buffers 93 | free(buffer2.data); 94 | free(tempBuffer); 95 | 96 | //create image context from buffer 97 | CGContextRef ctx = CGBitmapContextCreate(buffer1.data, buffer1.width, buffer1.height, 98 | 8, buffer1.rowBytes, CGImageGetColorSpace(imageRef), 99 | CGImageGetBitmapInfo(imageRef)); 100 | 101 | //apply tint 102 | if (tintColor && CGColorGetAlpha(tintColor.CGColor) > 0.0f) 103 | { 104 | CGContextSetFillColorWithColor(ctx, [tintColor colorWithAlphaComponent:0.25].CGColor); 105 | CGContextSetBlendMode(ctx, kCGBlendModePlusLighter); 106 | CGContextFillRect(ctx, CGRectMake(0, 0, buffer1.width, buffer1.height)); 107 | } 108 | 109 | //create image from context 110 | imageRef = CGBitmapContextCreateImage(ctx); 111 | UIImage *image = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation]; 112 | CGImageRelease(imageRef); 113 | CGContextRelease(ctx); 114 | free(buffer1.data); 115 | return image; 116 | } 117 | 118 | @end 119 | 120 | 121 | @interface FXBlurScheduler : NSObject 122 | 123 | @property (nonatomic, strong) NSMutableArray *views; 124 | @property (nonatomic, assign) NSUInteger viewIndex; 125 | @property (nonatomic, assign) NSUInteger updatesEnabled; 126 | @property (nonatomic, assign) BOOL blurEnabled; 127 | @property (nonatomic, assign) BOOL updating; 128 | 129 | @end 130 | 131 | 132 | @interface FXBlurLayer: CALayer 133 | 134 | @property (nonatomic, assign) CGFloat blurRadius; 135 | 136 | @end 137 | 138 | 139 | @implementation FXBlurLayer 140 | 141 | @dynamic blurRadius; 142 | 143 | + (BOOL)needsDisplayForKey:(NSString *)key 144 | { 145 | if ([@[@"blurRadius", @"bounds", @"position"] containsObject:key]) 146 | { 147 | return YES; 148 | } 149 | return [super needsDisplayForKey:key]; 150 | } 151 | 152 | @end 153 | 154 | 155 | @interface FXBlurView () 156 | 157 | @property (nonatomic, assign) BOOL iterationsSet; 158 | @property (nonatomic, assign) BOOL blurRadiusSet; 159 | @property (nonatomic, assign) BOOL dynamicSet; 160 | @property (nonatomic, assign) BOOL blurEnabledSet; 161 | @property (nonatomic, strong) NSDate *lastUpdate; 162 | 163 | - (UIImage *)snapshotOfUnderlyingView; 164 | - (BOOL)shouldUpdate; 165 | 166 | @end 167 | 168 | 169 | @implementation FXBlurScheduler 170 | 171 | + (instancetype)sharedInstance 172 | { 173 | static FXBlurScheduler *sharedInstance = nil; 174 | if (!sharedInstance) 175 | { 176 | sharedInstance = [[FXBlurScheduler alloc] init]; 177 | } 178 | return sharedInstance; 179 | } 180 | 181 | - (instancetype)init 182 | { 183 | if ((self = [super init])) 184 | { 185 | _updatesEnabled = 1; 186 | _blurEnabled = YES; 187 | _views = [[NSMutableArray alloc] init]; 188 | } 189 | return self; 190 | } 191 | 192 | - (void)setBlurEnabled:(BOOL)blurEnabled 193 | { 194 | _blurEnabled = blurEnabled; 195 | if (blurEnabled) 196 | { 197 | for (FXBlurView *view in self.views) 198 | { 199 | [view setNeedsDisplay]; 200 | } 201 | [self updateAsynchronously]; 202 | } 203 | } 204 | 205 | - (void)setUpdatesEnabled 206 | { 207 | _updatesEnabled ++; 208 | [self updateAsynchronously]; 209 | } 210 | 211 | - (void)setUpdatesDisabled 212 | { 213 | _updatesEnabled --; 214 | } 215 | 216 | - (void)addView:(FXBlurView *)view 217 | { 218 | if (![self.views containsObject:view]) 219 | { 220 | [self.views addObject:view]; 221 | [self updateAsynchronously]; 222 | } 223 | } 224 | 225 | - (void)removeView:(FXBlurView *)view 226 | { 227 | NSUInteger index = [self.views indexOfObject:view]; 228 | if (index != NSNotFound) 229 | { 230 | if (index <= self.viewIndex) 231 | { 232 | self.viewIndex --; 233 | } 234 | [self.views removeObjectAtIndex:index]; 235 | } 236 | } 237 | 238 | - (void)updateAsynchronously 239 | { 240 | if (self.blurEnabled && !self.updating && self.updatesEnabled > 0 && [self.views count]) 241 | { 242 | NSTimeInterval timeUntilNextUpdate = 1.0 / 60; 243 | 244 | //loop through until we find a view that's ready to be drawn 245 | self.viewIndex = self.viewIndex % [self.views count]; 246 | for (NSUInteger i = self.viewIndex; i < [self.views count]; i++) 247 | { 248 | FXBlurView *view = self.views[i]; 249 | if (view.dynamic && !view.hidden && view.window && [view shouldUpdate]) 250 | { 251 | NSTimeInterval nextUpdate = [view.lastUpdate timeIntervalSinceNow] + view.updateInterval; 252 | if (!view.lastUpdate || nextUpdate <= 0) 253 | { 254 | self.updating = YES; 255 | [view updateAsynchronously:YES completion:^{ 256 | 257 | //render next view 258 | self.updating = NO; 259 | self.viewIndex = i + 1; 260 | [self updateAsynchronously]; 261 | }]; 262 | return; 263 | } 264 | else 265 | { 266 | timeUntilNextUpdate = MIN(timeUntilNextUpdate, nextUpdate); 267 | } 268 | } 269 | } 270 | 271 | //try again, delaying until the time when the next view needs an update. 272 | self.viewIndex = 0; 273 | [self performSelector:@selector(updateAsynchronously) 274 | withObject:nil 275 | afterDelay:timeUntilNextUpdate 276 | inModes:@[NSDefaultRunLoopMode, UITrackingRunLoopMode]]; 277 | } 278 | } 279 | 280 | @end 281 | 282 | 283 | @implementation FXBlurView 284 | 285 | + (void)setBlurEnabled:(BOOL)blurEnabled 286 | { 287 | [FXBlurScheduler sharedInstance].blurEnabled = blurEnabled; 288 | } 289 | 290 | + (void)setUpdatesEnabled 291 | { 292 | [[FXBlurScheduler sharedInstance] setUpdatesEnabled]; 293 | } 294 | 295 | + (void)setUpdatesDisabled 296 | { 297 | [[FXBlurScheduler sharedInstance] setUpdatesDisabled]; 298 | } 299 | 300 | + (Class)layerClass 301 | { 302 | return [FXBlurLayer class]; 303 | } 304 | 305 | - (void)setUp 306 | { 307 | if (!_iterationsSet) _iterations = 3; 308 | if (!_blurRadiusSet) [self blurLayer].blurRadius = 40; 309 | if (!_dynamicSet) _dynamic = YES; 310 | if (!_blurEnabledSet) _blurEnabled = YES; 311 | self.updateInterval = _updateInterval; 312 | self.layer.magnificationFilter = @"linear"; // kCAFilterLinear 313 | 314 | unsigned int numberOfMethods; 315 | Method *methods = class_copyMethodList([UIView class], &numberOfMethods); 316 | for (unsigned int i = 0; i < numberOfMethods; i++) 317 | { 318 | Method method = methods[i]; 319 | SEL selector = method_getName(method); 320 | if (selector == @selector(tintColor)) 321 | { 322 | _tintColor = ((id (*)(id,SEL))method_getImplementation(method))(self, selector); 323 | break; 324 | } 325 | } 326 | free(methods); 327 | } 328 | 329 | - (id)initWithFrame:(CGRect)frame 330 | { 331 | if ((self = [super initWithFrame:frame])) 332 | { 333 | [self setUp]; 334 | self.clipsToBounds = YES; 335 | } 336 | return self; 337 | } 338 | 339 | - (id)initWithCoder:(NSCoder *)aDecoder 340 | { 341 | if ((self = [super initWithCoder:aDecoder])) 342 | { 343 | [self setUp]; 344 | } 345 | return self; 346 | } 347 | 348 | - (void)dealloc 349 | { 350 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 351 | } 352 | 353 | - (void)setIterations:(NSUInteger)iterations 354 | { 355 | _iterationsSet = YES; 356 | _iterations = iterations; 357 | [self setNeedsDisplay]; 358 | } 359 | 360 | - (void)setBlurRadius:(CGFloat)blurRadius 361 | { 362 | _blurRadiusSet = YES; 363 | [self blurLayer].blurRadius = blurRadius; 364 | } 365 | 366 | - (CGFloat)blurRadius 367 | { 368 | return [self blurLayer].blurRadius; 369 | } 370 | 371 | - (void)setBlurEnabled:(BOOL)blurEnabled 372 | { 373 | _blurEnabledSet = YES; 374 | if (_blurEnabled != blurEnabled) 375 | { 376 | _blurEnabled = blurEnabled; 377 | [self schedule]; 378 | if (_blurEnabled) 379 | { 380 | [self setNeedsDisplay]; 381 | } 382 | } 383 | } 384 | 385 | - (void)setDynamic:(BOOL)dynamic 386 | { 387 | _dynamicSet = YES; 388 | if (_dynamic != dynamic) 389 | { 390 | _dynamic = dynamic; 391 | [self schedule]; 392 | if (!dynamic) 393 | { 394 | [self setNeedsDisplay]; 395 | } 396 | } 397 | } 398 | 399 | - (UIView *)underlyingView 400 | { 401 | return _underlyingView ?: self.superview; 402 | } 403 | 404 | - (CALayer *)underlyingLayer 405 | { 406 | return self.underlyingView.layer; 407 | } 408 | 409 | - (FXBlurLayer *)blurLayer 410 | { 411 | return (FXBlurLayer *)self.layer; 412 | } 413 | 414 | - (FXBlurLayer *)blurPresentationLayer 415 | { 416 | FXBlurLayer *blurLayer = [self blurLayer]; 417 | return (FXBlurLayer *)blurLayer.presentationLayer ?: blurLayer; 418 | } 419 | 420 | - (void)setUpdateInterval:(NSTimeInterval)updateInterval 421 | { 422 | _updateInterval = updateInterval; 423 | if (_updateInterval <= 0) _updateInterval = 1.0/60; 424 | } 425 | 426 | - (void)setTintColor:(UIColor *)tintColor 427 | { 428 | _tintColor = tintColor; 429 | [self setNeedsDisplay]; 430 | } 431 | 432 | - (void)didMoveToSuperview 433 | { 434 | [super didMoveToSuperview]; 435 | [self.layer setNeedsDisplay]; 436 | } 437 | 438 | - (void)didMoveToWindow 439 | { 440 | [super didMoveToWindow]; 441 | [self schedule]; 442 | } 443 | 444 | - (void)schedule 445 | { 446 | if (self.window && self.dynamic && self.blurEnabled) 447 | { 448 | [[FXBlurScheduler sharedInstance] addView:self]; 449 | } 450 | else 451 | { 452 | [[FXBlurScheduler sharedInstance] removeView:self]; 453 | } 454 | } 455 | 456 | - (void)setNeedsDisplay 457 | { 458 | [super setNeedsDisplay]; 459 | [self.layer setNeedsDisplay]; 460 | } 461 | 462 | - (BOOL)shouldUpdate 463 | { 464 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 465 | 466 | return 467 | underlyingLayer && !underlyingLayer.hidden && 468 | self.blurEnabled && [FXBlurScheduler sharedInstance].blurEnabled && 469 | !CGRectIsEmpty([self.layer.presentationLayer ?: self.layer bounds]) && !CGRectIsEmpty(underlyingLayer.bounds); 470 | } 471 | 472 | - (void)displayLayer:(__unused CALayer *)layer 473 | { 474 | [self updateAsynchronously:NO completion:NULL]; 475 | } 476 | 477 | - (id)actionForLayer:(CALayer *)layer forKey:(NSString *)key 478 | { 479 | if ([key isEqualToString:@"blurRadius"]) 480 | { 481 | //animations are enabled 482 | CAAnimation *action = (CAAnimation *)[super actionForLayer:layer forKey:@"bounds"]; 483 | if ((NSNull *)action != [NSNull null]) 484 | { 485 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key]; 486 | animation.fromValue = [layer.presentationLayer valueForKey:key]; 487 | animation.duration = action.duration; 488 | animation.timingFunction = action.timingFunction; 489 | animation.timeOffset = action.timeOffset; 490 | animation.delegate = action.delegate; 491 | return animation; 492 | } 493 | } 494 | return [super actionForLayer:layer forKey:key]; 495 | } 496 | 497 | - (UIImage *)snapshotOfUnderlyingView 498 | { 499 | __strong FXBlurLayer *blurLayer = [self blurPresentationLayer]; 500 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 501 | CGRect bounds = [blurLayer convertRect:blurLayer.bounds toLayer:underlyingLayer]; 502 | 503 | self.lastUpdate = [NSDate date]; 504 | CGFloat scale = 0.5; 505 | if (self.iterations) 506 | { 507 | CGFloat blockSize = 12.0f/self.iterations; 508 | scale = blockSize/MAX(blockSize * 2, blurLayer.blurRadius); 509 | scale = 1.0f/floorf(1.0f/scale); 510 | } 511 | CGSize size = bounds.size; 512 | if (self.contentMode == UIViewContentModeScaleToFill || 513 | self.contentMode == UIViewContentModeScaleAspectFill || 514 | self.contentMode == UIViewContentModeScaleAspectFit || 515 | self.contentMode == UIViewContentModeRedraw) 516 | { 517 | //prevents edge artefacts 518 | size.width = floorf(size.width * scale) / scale; 519 | size.height = floorf(size.height * scale) / scale; 520 | } 521 | else if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0f && [UIScreen mainScreen].scale == 1.0f) 522 | { 523 | //prevents pixelation on old devices 524 | scale = 1.0f; 525 | } 526 | UIGraphicsBeginImageContextWithOptions(size, YES, scale); 527 | CGContextRef context = UIGraphicsGetCurrentContext(); 528 | CGContextTranslateCTM(context, -bounds.origin.x, -bounds.origin.y); 529 | 530 | NSArray *hiddenViews = [self prepareUnderlyingViewForSnapshot]; 531 | [underlyingLayer renderInContext:context]; 532 | [self restoreSuperviewAfterSnapshot:hiddenViews]; 533 | UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); 534 | UIGraphicsEndImageContext(); 535 | return snapshot; 536 | } 537 | 538 | - (NSArray *)prepareUnderlyingViewForSnapshot 539 | { 540 | __strong CALayer *blurlayer = [self blurLayer]; 541 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 542 | while (blurlayer.superlayer && blurlayer.superlayer != underlyingLayer) 543 | { 544 | blurlayer = blurlayer.superlayer; 545 | } 546 | NSMutableArray *layers = [NSMutableArray array]; 547 | NSUInteger index = [underlyingLayer.sublayers indexOfObject:blurlayer]; 548 | if (index != NSNotFound) 549 | { 550 | for (NSUInteger i = index; i < [underlyingLayer.sublayers count]; i++) 551 | { 552 | CALayer *layer = underlyingLayer.sublayers[i]; 553 | if (!layer.hidden) 554 | { 555 | layer.hidden = YES; 556 | [layers addObject:layer]; 557 | } 558 | } 559 | } 560 | return layers; 561 | } 562 | 563 | - (void)restoreSuperviewAfterSnapshot:(NSArray *)hiddenLayers 564 | { 565 | for (CALayer *layer in hiddenLayers) 566 | { 567 | layer.hidden = NO; 568 | } 569 | } 570 | 571 | - (UIImage *)blurredSnapshot:(UIImage *)snapshot radius:(CGFloat)blurRadius 572 | { 573 | return [snapshot blurredImageWithRadius:blurRadius 574 | iterations:self.iterations 575 | tintColor:self.tintColor]; 576 | } 577 | 578 | - (void)setLayerContents:(UIImage *)image 579 | { 580 | self.layer.contents = (id)image.CGImage; 581 | self.layer.contentsScale = image.scale; 582 | } 583 | 584 | - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion 585 | { 586 | if ([self shouldUpdate]) 587 | { 588 | UIImage *snapshot = [self snapshotOfUnderlyingView]; 589 | if (async) 590 | { 591 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 592 | 593 | UIImage *blurredImage = [self blurredSnapshot:snapshot radius:self.blurRadius]; 594 | dispatch_sync(dispatch_get_main_queue(), ^{ 595 | 596 | [self setLayerContents:blurredImage]; 597 | if (completion) completion(); 598 | }); 599 | }); 600 | } 601 | else 602 | { 603 | [self setLayerContents:[self blurredSnapshot:snapshot radius:[self blurPresentationLayer].blurRadius]]; 604 | if (completion) completion(); 605 | } 606 | } 607 | else if (completion) 608 | { 609 | completion(); 610 | } 611 | } 612 | 613 | @end 614 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenu/Supporting/FXBlurView/FXBlurView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FXBlurView.m 3 | // 4 | // Version 1.6.1 5 | // 6 | // Created by Nick Lockwood on 25/08/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FXBlurView 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import "FXBlurView.h" 35 | #import 36 | #import 37 | #import 38 | 39 | 40 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 41 | #pragma GCC diagnostic ignored "-Wdirect-ivar-access" 42 | #pragma GCC diagnostic ignored "-Wgnu" 43 | 44 | 45 | #import 46 | #if !__has_feature(objc_arc) 47 | #error This class requires automatic reference counting 48 | #endif 49 | 50 | 51 | @implementation UIImage (FXBlurView) 52 | 53 | - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor 54 | { 55 | //image must be nonzero size 56 | if (floorf(self.size.width) * floorf(self.size.height) <= 0.0f) return self; 57 | 58 | //boxsize must be an odd integer 59 | uint32_t boxSize = (uint32_t)(radius * self.scale); 60 | if (boxSize % 2 == 0) boxSize ++; 61 | 62 | //create image buffers 63 | CGImageRef imageRef = self.CGImage; 64 | vImage_Buffer buffer1, buffer2; 65 | buffer1.width = buffer2.width = CGImageGetWidth(imageRef); 66 | buffer1.height = buffer2.height = CGImageGetHeight(imageRef); 67 | buffer1.rowBytes = buffer2.rowBytes = CGImageGetBytesPerRow(imageRef); 68 | size_t bytes = buffer1.rowBytes * buffer1.height; 69 | buffer1.data = malloc(bytes); 70 | buffer2.data = malloc(bytes); 71 | 72 | //create temp buffer 73 | void *tempBuffer = malloc((size_t)vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, NULL, 0, 0, boxSize, boxSize, 74 | NULL, kvImageEdgeExtend + kvImageGetTempBufferSize)); 75 | 76 | //copy image data 77 | CFDataRef dataSource = CGDataProviderCopyData(CGImageGetDataProvider(imageRef)); 78 | memcpy(buffer1.data, CFDataGetBytePtr(dataSource), bytes); 79 | CFRelease(dataSource); 80 | 81 | for (NSUInteger i = 0; i < iterations; i++) 82 | { 83 | //perform blur 84 | vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, tempBuffer, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend); 85 | 86 | //swap buffers 87 | void *temp = buffer1.data; 88 | buffer1.data = buffer2.data; 89 | buffer2.data = temp; 90 | } 91 | 92 | //free buffers 93 | free(buffer2.data); 94 | free(tempBuffer); 95 | 96 | //create image context from buffer 97 | CGContextRef ctx = CGBitmapContextCreate(buffer1.data, buffer1.width, buffer1.height, 98 | 8, buffer1.rowBytes, CGImageGetColorSpace(imageRef), 99 | CGImageGetBitmapInfo(imageRef)); 100 | 101 | //apply tint 102 | if (tintColor && CGColorGetAlpha(tintColor.CGColor) > 0.0f) 103 | { 104 | CGContextSetFillColorWithColor(ctx, [tintColor colorWithAlphaComponent:0.25].CGColor); 105 | CGContextSetBlendMode(ctx, kCGBlendModePlusLighter); 106 | CGContextFillRect(ctx, CGRectMake(0, 0, buffer1.width, buffer1.height)); 107 | } 108 | 109 | //create image from context 110 | imageRef = CGBitmapContextCreateImage(ctx); 111 | UIImage *image = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation]; 112 | CGImageRelease(imageRef); 113 | CGContextRelease(ctx); 114 | free(buffer1.data); 115 | return image; 116 | } 117 | 118 | @end 119 | 120 | 121 | @interface FXBlurScheduler : NSObject 122 | 123 | @property (nonatomic, strong) NSMutableArray *views; 124 | @property (nonatomic, assign) NSUInteger viewIndex; 125 | @property (nonatomic, assign) NSUInteger updatesEnabled; 126 | @property (nonatomic, assign) BOOL blurEnabled; 127 | @property (nonatomic, assign) BOOL updating; 128 | 129 | @end 130 | 131 | 132 | @interface FXBlurLayer: CALayer 133 | 134 | @property (nonatomic, assign) CGFloat blurRadius; 135 | 136 | @end 137 | 138 | 139 | @implementation FXBlurLayer 140 | 141 | @dynamic blurRadius; 142 | 143 | + (BOOL)needsDisplayForKey:(NSString *)key 144 | { 145 | if ([@[@"blurRadius", @"bounds", @"position"] containsObject:key]) 146 | { 147 | return YES; 148 | } 149 | return [super needsDisplayForKey:key]; 150 | } 151 | 152 | @end 153 | 154 | 155 | @interface FXBlurView () 156 | 157 | @property (nonatomic, assign) BOOL iterationsSet; 158 | @property (nonatomic, assign) BOOL blurRadiusSet; 159 | @property (nonatomic, assign) BOOL dynamicSet; 160 | @property (nonatomic, assign) BOOL blurEnabledSet; 161 | @property (nonatomic, strong) NSDate *lastUpdate; 162 | 163 | - (UIImage *)snapshotOfUnderlyingView; 164 | - (BOOL)shouldUpdate; 165 | 166 | @end 167 | 168 | 169 | @implementation FXBlurScheduler 170 | 171 | + (instancetype)sharedInstance 172 | { 173 | static FXBlurScheduler *sharedInstance = nil; 174 | if (!sharedInstance) 175 | { 176 | sharedInstance = [[FXBlurScheduler alloc] init]; 177 | } 178 | return sharedInstance; 179 | } 180 | 181 | - (instancetype)init 182 | { 183 | if ((self = [super init])) 184 | { 185 | _updatesEnabled = 1; 186 | _blurEnabled = YES; 187 | _views = [[NSMutableArray alloc] init]; 188 | } 189 | return self; 190 | } 191 | 192 | - (void)setBlurEnabled:(BOOL)blurEnabled 193 | { 194 | _blurEnabled = blurEnabled; 195 | if (blurEnabled) 196 | { 197 | for (FXBlurView *view in self.views) 198 | { 199 | [view setNeedsDisplay]; 200 | } 201 | [self updateAsynchronously]; 202 | } 203 | } 204 | 205 | - (void)setUpdatesEnabled 206 | { 207 | _updatesEnabled ++; 208 | [self updateAsynchronously]; 209 | } 210 | 211 | - (void)setUpdatesDisabled 212 | { 213 | _updatesEnabled --; 214 | } 215 | 216 | - (void)addView:(FXBlurView *)view 217 | { 218 | if (![self.views containsObject:view]) 219 | { 220 | [self.views addObject:view]; 221 | [self updateAsynchronously]; 222 | } 223 | } 224 | 225 | - (void)removeView:(FXBlurView *)view 226 | { 227 | NSUInteger index = [self.views indexOfObject:view]; 228 | if (index != NSNotFound) 229 | { 230 | if (index <= self.viewIndex) 231 | { 232 | self.viewIndex --; 233 | } 234 | [self.views removeObjectAtIndex:index]; 235 | } 236 | } 237 | 238 | - (void)updateAsynchronously 239 | { 240 | if (self.blurEnabled && !self.updating && self.updatesEnabled > 0 && [self.views count]) 241 | { 242 | NSTimeInterval timeUntilNextUpdate = 1.0 / 60; 243 | 244 | //loop through until we find a view that's ready to be drawn 245 | self.viewIndex = self.viewIndex % [self.views count]; 246 | for (NSUInteger i = self.viewIndex; i < [self.views count]; i++) 247 | { 248 | FXBlurView *view = self.views[i]; 249 | if (view.dynamic && !view.hidden && view.window && [view shouldUpdate]) 250 | { 251 | NSTimeInterval nextUpdate = [view.lastUpdate timeIntervalSinceNow] + view.updateInterval; 252 | if (!view.lastUpdate || nextUpdate <= 0) 253 | { 254 | self.updating = YES; 255 | [view updateAsynchronously:YES completion:^{ 256 | 257 | //render next view 258 | self.updating = NO; 259 | self.viewIndex = i + 1; 260 | [self updateAsynchronously]; 261 | }]; 262 | return; 263 | } 264 | else 265 | { 266 | timeUntilNextUpdate = MIN(timeUntilNextUpdate, nextUpdate); 267 | } 268 | } 269 | } 270 | 271 | //try again, delaying until the time when the next view needs an update. 272 | self.viewIndex = 0; 273 | [self performSelector:@selector(updateAsynchronously) 274 | withObject:nil 275 | afterDelay:timeUntilNextUpdate 276 | inModes:@[NSDefaultRunLoopMode, UITrackingRunLoopMode]]; 277 | } 278 | } 279 | 280 | @end 281 | 282 | 283 | @implementation FXBlurView 284 | 285 | + (void)setBlurEnabled:(BOOL)blurEnabled 286 | { 287 | [FXBlurScheduler sharedInstance].blurEnabled = blurEnabled; 288 | } 289 | 290 | + (void)setUpdatesEnabled 291 | { 292 | [[FXBlurScheduler sharedInstance] setUpdatesEnabled]; 293 | } 294 | 295 | + (void)setUpdatesDisabled 296 | { 297 | [[FXBlurScheduler sharedInstance] setUpdatesDisabled]; 298 | } 299 | 300 | + (Class)layerClass 301 | { 302 | return [FXBlurLayer class]; 303 | } 304 | 305 | - (void)setUp 306 | { 307 | if (!_iterationsSet) _iterations = 3; 308 | if (!_blurRadiusSet) [self blurLayer].blurRadius = 40; 309 | if (!_dynamicSet) _dynamic = YES; 310 | if (!_blurEnabledSet) _blurEnabled = YES; 311 | self.updateInterval = _updateInterval; 312 | self.layer.magnificationFilter = @"linear"; // kCAFilterLinear 313 | 314 | unsigned int numberOfMethods; 315 | Method *methods = class_copyMethodList([UIView class], &numberOfMethods); 316 | for (unsigned int i = 0; i < numberOfMethods; i++) 317 | { 318 | Method method = methods[i]; 319 | SEL selector = method_getName(method); 320 | if (selector == @selector(tintColor)) 321 | { 322 | _tintColor = ((id (*)(id,SEL))method_getImplementation(method))(self, selector); 323 | break; 324 | } 325 | } 326 | free(methods); 327 | } 328 | 329 | - (id)initWithFrame:(CGRect)frame 330 | { 331 | if ((self = [super initWithFrame:frame])) 332 | { 333 | [self setUp]; 334 | self.clipsToBounds = YES; 335 | } 336 | return self; 337 | } 338 | 339 | - (id)initWithCoder:(NSCoder *)aDecoder 340 | { 341 | if ((self = [super initWithCoder:aDecoder])) 342 | { 343 | [self setUp]; 344 | } 345 | return self; 346 | } 347 | 348 | - (void)dealloc 349 | { 350 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 351 | } 352 | 353 | - (void)setIterations:(NSUInteger)iterations 354 | { 355 | _iterationsSet = YES; 356 | _iterations = iterations; 357 | [self setNeedsDisplay]; 358 | } 359 | 360 | - (void)setBlurRadius:(CGFloat)blurRadius 361 | { 362 | _blurRadiusSet = YES; 363 | [self blurLayer].blurRadius = blurRadius; 364 | } 365 | 366 | - (CGFloat)blurRadius 367 | { 368 | return [self blurLayer].blurRadius; 369 | } 370 | 371 | - (void)setBlurEnabled:(BOOL)blurEnabled 372 | { 373 | _blurEnabledSet = YES; 374 | if (_blurEnabled != blurEnabled) 375 | { 376 | _blurEnabled = blurEnabled; 377 | [self schedule]; 378 | if (_blurEnabled) 379 | { 380 | [self setNeedsDisplay]; 381 | } 382 | } 383 | } 384 | 385 | - (void)setDynamic:(BOOL)dynamic 386 | { 387 | _dynamicSet = YES; 388 | if (_dynamic != dynamic) 389 | { 390 | _dynamic = dynamic; 391 | [self schedule]; 392 | if (!dynamic) 393 | { 394 | [self setNeedsDisplay]; 395 | } 396 | } 397 | } 398 | 399 | - (UIView *)underlyingView 400 | { 401 | return _underlyingView ?: self.superview; 402 | } 403 | 404 | - (CALayer *)underlyingLayer 405 | { 406 | return self.underlyingView.layer; 407 | } 408 | 409 | - (FXBlurLayer *)blurLayer 410 | { 411 | return (FXBlurLayer *)self.layer; 412 | } 413 | 414 | - (FXBlurLayer *)blurPresentationLayer 415 | { 416 | FXBlurLayer *blurLayer = [self blurLayer]; 417 | return (FXBlurLayer *)blurLayer.presentationLayer ?: blurLayer; 418 | } 419 | 420 | - (void)setUpdateInterval:(NSTimeInterval)updateInterval 421 | { 422 | _updateInterval = updateInterval; 423 | if (_updateInterval <= 0) _updateInterval = 1.0/60; 424 | } 425 | 426 | - (void)setTintColor:(UIColor *)tintColor 427 | { 428 | _tintColor = tintColor; 429 | [self setNeedsDisplay]; 430 | } 431 | 432 | - (void)didMoveToSuperview 433 | { 434 | [super didMoveToSuperview]; 435 | [self.layer setNeedsDisplay]; 436 | } 437 | 438 | - (void)didMoveToWindow 439 | { 440 | [super didMoveToWindow]; 441 | [self schedule]; 442 | } 443 | 444 | - (void)schedule 445 | { 446 | if (self.window && self.dynamic && self.blurEnabled) 447 | { 448 | [[FXBlurScheduler sharedInstance] addView:self]; 449 | } 450 | else 451 | { 452 | [[FXBlurScheduler sharedInstance] removeView:self]; 453 | } 454 | } 455 | 456 | - (void)setNeedsDisplay 457 | { 458 | [super setNeedsDisplay]; 459 | [self.layer setNeedsDisplay]; 460 | } 461 | 462 | - (BOOL)shouldUpdate 463 | { 464 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 465 | 466 | return 467 | underlyingLayer && !underlyingLayer.hidden && 468 | self.blurEnabled && [FXBlurScheduler sharedInstance].blurEnabled && 469 | !CGRectIsEmpty([self.layer.presentationLayer ?: self.layer bounds]) && !CGRectIsEmpty(underlyingLayer.bounds); 470 | } 471 | 472 | - (void)displayLayer:(__unused CALayer *)layer 473 | { 474 | [self updateAsynchronously:NO completion:NULL]; 475 | } 476 | 477 | - (id)actionForLayer:(CALayer *)layer forKey:(NSString *)key 478 | { 479 | if ([key isEqualToString:@"blurRadius"]) 480 | { 481 | //animations are enabled 482 | CAAnimation *action = (CAAnimation *)[super actionForLayer:layer forKey:@"bounds"]; 483 | if ((NSNull *)action != [NSNull null]) 484 | { 485 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key]; 486 | animation.fromValue = [layer.presentationLayer valueForKey:key]; 487 | animation.duration = action.duration; 488 | animation.timingFunction = action.timingFunction; 489 | animation.timeOffset = action.timeOffset; 490 | animation.delegate = action.delegate; 491 | return animation; 492 | } 493 | } 494 | return [super actionForLayer:layer forKey:key]; 495 | } 496 | 497 | - (UIImage *)snapshotOfUnderlyingView 498 | { 499 | __strong FXBlurLayer *blurLayer = [self blurPresentationLayer]; 500 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 501 | CGRect bounds = [blurLayer convertRect:blurLayer.bounds toLayer:underlyingLayer]; 502 | 503 | self.lastUpdate = [NSDate date]; 504 | CGFloat scale = 0.5; 505 | if (self.iterations) 506 | { 507 | CGFloat blockSize = 12.0f/self.iterations; 508 | scale = blockSize/MAX(blockSize * 2, blurLayer.blurRadius); 509 | scale = 1.0f/floorf(1.0f/scale); 510 | } 511 | CGSize size = bounds.size; 512 | if (self.contentMode == UIViewContentModeScaleToFill || 513 | self.contentMode == UIViewContentModeScaleAspectFill || 514 | self.contentMode == UIViewContentModeScaleAspectFit || 515 | self.contentMode == UIViewContentModeRedraw) 516 | { 517 | //prevents edge artefacts 518 | size.width = floorf(size.width * scale) / scale; 519 | size.height = floorf(size.height * scale) / scale; 520 | } 521 | else if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0f && [UIScreen mainScreen].scale == 1.0f) 522 | { 523 | //prevents pixelation on old devices 524 | scale = 1.0f; 525 | } 526 | UIGraphicsBeginImageContextWithOptions(size, YES, scale); 527 | CGContextRef context = UIGraphicsGetCurrentContext(); 528 | CGContextTranslateCTM(context, -bounds.origin.x, -bounds.origin.y); 529 | 530 | NSArray *hiddenViews = [self prepareUnderlyingViewForSnapshot]; 531 | [underlyingLayer renderInContext:context]; 532 | [self restoreSuperviewAfterSnapshot:hiddenViews]; 533 | UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); 534 | UIGraphicsEndImageContext(); 535 | return snapshot; 536 | } 537 | 538 | - (NSArray *)prepareUnderlyingViewForSnapshot 539 | { 540 | __strong CALayer *blurlayer = [self blurLayer]; 541 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 542 | while (blurlayer.superlayer && blurlayer.superlayer != underlyingLayer) 543 | { 544 | blurlayer = blurlayer.superlayer; 545 | } 546 | NSMutableArray *layers = [NSMutableArray array]; 547 | NSUInteger index = [underlyingLayer.sublayers indexOfObject:blurlayer]; 548 | if (index != NSNotFound) 549 | { 550 | for (NSUInteger i = index; i < [underlyingLayer.sublayers count]; i++) 551 | { 552 | CALayer *layer = underlyingLayer.sublayers[i]; 553 | if (!layer.hidden) 554 | { 555 | layer.hidden = YES; 556 | [layers addObject:layer]; 557 | } 558 | } 559 | } 560 | return layers; 561 | } 562 | 563 | - (void)restoreSuperviewAfterSnapshot:(NSArray *)hiddenLayers 564 | { 565 | for (CALayer *layer in hiddenLayers) 566 | { 567 | layer.hidden = NO; 568 | } 569 | } 570 | 571 | - (UIImage *)blurredSnapshot:(UIImage *)snapshot radius:(CGFloat)blurRadius 572 | { 573 | return [snapshot blurredImageWithRadius:blurRadius 574 | iterations:self.iterations 575 | tintColor:self.tintColor]; 576 | } 577 | 578 | - (void)setLayerContents:(UIImage *)image 579 | { 580 | self.layer.contents = (id)image.CGImage; 581 | self.layer.contentsScale = image.scale; 582 | } 583 | 584 | - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion 585 | { 586 | if ([self shouldUpdate]) 587 | { 588 | UIImage *snapshot = [self snapshotOfUnderlyingView]; 589 | if (async) 590 | { 591 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 592 | 593 | UIImage *blurredImage = [self blurredSnapshot:snapshot radius:self.blurRadius]; 594 | dispatch_sync(dispatch_get_main_queue(), ^{ 595 | 596 | [self setLayerContents:blurredImage]; 597 | if (completion) completion(); 598 | }); 599 | }); 600 | } 601 | else 602 | { 603 | [self setLayerContents:[self blurredSnapshot:snapshot radius:[self blurPresentationLayer].blurRadius]]; 604 | if (completion) completion(); 605 | } 606 | } 607 | else if (completion) 608 | { 609 | completion(); 610 | } 611 | } 612 | 613 | @end 614 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo/OECentreMenu/Supporting/FXBlurView/FXBlurView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FXBlurView.m 3 | // 4 | // Version 1.6.1 5 | // 6 | // Created by Nick Lockwood on 25/08/2013. 7 | // Copyright (c) 2013 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/FXBlurView 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | 34 | #import "FXBlurView.h" 35 | #import 36 | #import 37 | #import 38 | 39 | 40 | #pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis" 41 | #pragma GCC diagnostic ignored "-Wdirect-ivar-access" 42 | #pragma GCC diagnostic ignored "-Wgnu" 43 | 44 | 45 | #import 46 | #if !__has_feature(objc_arc) 47 | #error This class requires automatic reference counting 48 | #endif 49 | 50 | 51 | @implementation UIImage (FXBlurView) 52 | 53 | - (UIImage *)blurredImageWithRadius:(CGFloat)radius iterations:(NSUInteger)iterations tintColor:(UIColor *)tintColor 54 | { 55 | //image must be nonzero size 56 | if (floorf(self.size.width) * floorf(self.size.height) <= 0.0f) return self; 57 | 58 | //boxsize must be an odd integer 59 | uint32_t boxSize = (uint32_t)(radius * self.scale); 60 | if (boxSize % 2 == 0) boxSize ++; 61 | 62 | //create image buffers 63 | CGImageRef imageRef = self.CGImage; 64 | vImage_Buffer buffer1, buffer2; 65 | buffer1.width = buffer2.width = CGImageGetWidth(imageRef); 66 | buffer1.height = buffer2.height = CGImageGetHeight(imageRef); 67 | buffer1.rowBytes = buffer2.rowBytes = CGImageGetBytesPerRow(imageRef); 68 | size_t bytes = buffer1.rowBytes * buffer1.height; 69 | buffer1.data = malloc(bytes); 70 | buffer2.data = malloc(bytes); 71 | 72 | //create temp buffer 73 | void *tempBuffer = malloc((size_t)vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, NULL, 0, 0, boxSize, boxSize, 74 | NULL, kvImageEdgeExtend + kvImageGetTempBufferSize)); 75 | 76 | //copy image data 77 | CFDataRef dataSource = CGDataProviderCopyData(CGImageGetDataProvider(imageRef)); 78 | memcpy(buffer1.data, CFDataGetBytePtr(dataSource), bytes); 79 | CFRelease(dataSource); 80 | 81 | for (NSUInteger i = 0; i < iterations; i++) 82 | { 83 | //perform blur 84 | vImageBoxConvolve_ARGB8888(&buffer1, &buffer2, tempBuffer, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend); 85 | 86 | //swap buffers 87 | void *temp = buffer1.data; 88 | buffer1.data = buffer2.data; 89 | buffer2.data = temp; 90 | } 91 | 92 | //free buffers 93 | free(buffer2.data); 94 | free(tempBuffer); 95 | 96 | //create image context from buffer 97 | CGContextRef ctx = CGBitmapContextCreate(buffer1.data, buffer1.width, buffer1.height, 98 | 8, buffer1.rowBytes, CGImageGetColorSpace(imageRef), 99 | CGImageGetBitmapInfo(imageRef)); 100 | 101 | //apply tint 102 | if (tintColor && CGColorGetAlpha(tintColor.CGColor) > 0.0f) 103 | { 104 | CGContextSetFillColorWithColor(ctx, [tintColor colorWithAlphaComponent:0.25].CGColor); 105 | CGContextSetBlendMode(ctx, kCGBlendModePlusLighter); 106 | CGContextFillRect(ctx, CGRectMake(0, 0, buffer1.width, buffer1.height)); 107 | } 108 | 109 | //create image from context 110 | imageRef = CGBitmapContextCreateImage(ctx); 111 | UIImage *image = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation]; 112 | CGImageRelease(imageRef); 113 | CGContextRelease(ctx); 114 | free(buffer1.data); 115 | return image; 116 | } 117 | 118 | @end 119 | 120 | 121 | @interface FXBlurScheduler : NSObject 122 | 123 | @property (nonatomic, strong) NSMutableArray *views; 124 | @property (nonatomic, assign) NSUInteger viewIndex; 125 | @property (nonatomic, assign) NSUInteger updatesEnabled; 126 | @property (nonatomic, assign) BOOL blurEnabled; 127 | @property (nonatomic, assign) BOOL updating; 128 | 129 | @end 130 | 131 | 132 | @interface FXBlurLayer: CALayer 133 | 134 | @property (nonatomic, assign) CGFloat blurRadius; 135 | 136 | @end 137 | 138 | 139 | @implementation FXBlurLayer 140 | 141 | @dynamic blurRadius; 142 | 143 | + (BOOL)needsDisplayForKey:(NSString *)key 144 | { 145 | if ([@[@"blurRadius", @"bounds", @"position"] containsObject:key]) 146 | { 147 | return YES; 148 | } 149 | return [super needsDisplayForKey:key]; 150 | } 151 | 152 | @end 153 | 154 | 155 | @interface FXBlurView () 156 | 157 | @property (nonatomic, assign) BOOL iterationsSet; 158 | @property (nonatomic, assign) BOOL blurRadiusSet; 159 | @property (nonatomic, assign) BOOL dynamicSet; 160 | @property (nonatomic, assign) BOOL blurEnabledSet; 161 | @property (nonatomic, strong) NSDate *lastUpdate; 162 | 163 | - (UIImage *)snapshotOfUnderlyingView; 164 | - (BOOL)shouldUpdate; 165 | 166 | @end 167 | 168 | 169 | @implementation FXBlurScheduler 170 | 171 | + (instancetype)sharedInstance 172 | { 173 | static FXBlurScheduler *sharedInstance = nil; 174 | if (!sharedInstance) 175 | { 176 | sharedInstance = [[FXBlurScheduler alloc] init]; 177 | } 178 | return sharedInstance; 179 | } 180 | 181 | - (instancetype)init 182 | { 183 | if ((self = [super init])) 184 | { 185 | _updatesEnabled = 1; 186 | _blurEnabled = YES; 187 | _views = [[NSMutableArray alloc] init]; 188 | } 189 | return self; 190 | } 191 | 192 | - (void)setBlurEnabled:(BOOL)blurEnabled 193 | { 194 | _blurEnabled = blurEnabled; 195 | if (blurEnabled) 196 | { 197 | for (FXBlurView *view in self.views) 198 | { 199 | [view setNeedsDisplay]; 200 | } 201 | [self updateAsynchronously]; 202 | } 203 | } 204 | 205 | - (void)setUpdatesEnabled 206 | { 207 | _updatesEnabled ++; 208 | [self updateAsynchronously]; 209 | } 210 | 211 | - (void)setUpdatesDisabled 212 | { 213 | _updatesEnabled --; 214 | } 215 | 216 | - (void)addView:(FXBlurView *)view 217 | { 218 | if (![self.views containsObject:view]) 219 | { 220 | [self.views addObject:view]; 221 | [self updateAsynchronously]; 222 | } 223 | } 224 | 225 | - (void)removeView:(FXBlurView *)view 226 | { 227 | NSUInteger index = [self.views indexOfObject:view]; 228 | if (index != NSNotFound) 229 | { 230 | if (index <= self.viewIndex) 231 | { 232 | self.viewIndex --; 233 | } 234 | [self.views removeObjectAtIndex:index]; 235 | } 236 | } 237 | 238 | - (void)updateAsynchronously 239 | { 240 | if (self.blurEnabled && !self.updating && self.updatesEnabled > 0 && [self.views count]) 241 | { 242 | NSTimeInterval timeUntilNextUpdate = 1.0 / 60; 243 | 244 | //loop through until we find a view that's ready to be drawn 245 | self.viewIndex = self.viewIndex % [self.views count]; 246 | for (NSUInteger i = self.viewIndex; i < [self.views count]; i++) 247 | { 248 | FXBlurView *view = self.views[i]; 249 | if (view.dynamic && !view.hidden && view.window && [view shouldUpdate]) 250 | { 251 | NSTimeInterval nextUpdate = [view.lastUpdate timeIntervalSinceNow] + view.updateInterval; 252 | if (!view.lastUpdate || nextUpdate <= 0) 253 | { 254 | self.updating = YES; 255 | [view updateAsynchronously:YES completion:^{ 256 | 257 | //render next view 258 | self.updating = NO; 259 | self.viewIndex = i + 1; 260 | [self updateAsynchronously]; 261 | }]; 262 | return; 263 | } 264 | else 265 | { 266 | timeUntilNextUpdate = MIN(timeUntilNextUpdate, nextUpdate); 267 | } 268 | } 269 | } 270 | 271 | //try again, delaying until the time when the next view needs an update. 272 | self.viewIndex = 0; 273 | [self performSelector:@selector(updateAsynchronously) 274 | withObject:nil 275 | afterDelay:timeUntilNextUpdate 276 | inModes:@[NSDefaultRunLoopMode, UITrackingRunLoopMode]]; 277 | } 278 | } 279 | 280 | @end 281 | 282 | 283 | @implementation FXBlurView 284 | 285 | + (void)setBlurEnabled:(BOOL)blurEnabled 286 | { 287 | [FXBlurScheduler sharedInstance].blurEnabled = blurEnabled; 288 | } 289 | 290 | + (void)setUpdatesEnabled 291 | { 292 | [[FXBlurScheduler sharedInstance] setUpdatesEnabled]; 293 | } 294 | 295 | + (void)setUpdatesDisabled 296 | { 297 | [[FXBlurScheduler sharedInstance] setUpdatesDisabled]; 298 | } 299 | 300 | + (Class)layerClass 301 | { 302 | return [FXBlurLayer class]; 303 | } 304 | 305 | - (void)setUp 306 | { 307 | if (!_iterationsSet) _iterations = 3; 308 | if (!_blurRadiusSet) [self blurLayer].blurRadius = 40; 309 | if (!_dynamicSet) _dynamic = YES; 310 | if (!_blurEnabledSet) _blurEnabled = YES; 311 | self.updateInterval = _updateInterval; 312 | self.layer.magnificationFilter = @"linear"; // kCAFilterLinear 313 | 314 | unsigned int numberOfMethods; 315 | Method *methods = class_copyMethodList([UIView class], &numberOfMethods); 316 | for (unsigned int i = 0; i < numberOfMethods; i++) 317 | { 318 | Method method = methods[i]; 319 | SEL selector = method_getName(method); 320 | if (selector == @selector(tintColor)) 321 | { 322 | _tintColor = ((id (*)(id,SEL))method_getImplementation(method))(self, selector); 323 | break; 324 | } 325 | } 326 | free(methods); 327 | } 328 | 329 | - (id)initWithFrame:(CGRect)frame 330 | { 331 | if ((self = [super initWithFrame:frame])) 332 | { 333 | [self setUp]; 334 | self.clipsToBounds = YES; 335 | } 336 | return self; 337 | } 338 | 339 | - (id)initWithCoder:(NSCoder *)aDecoder 340 | { 341 | if ((self = [super initWithCoder:aDecoder])) 342 | { 343 | [self setUp]; 344 | } 345 | return self; 346 | } 347 | 348 | - (void)dealloc 349 | { 350 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 351 | } 352 | 353 | - (void)setIterations:(NSUInteger)iterations 354 | { 355 | _iterationsSet = YES; 356 | _iterations = iterations; 357 | [self setNeedsDisplay]; 358 | } 359 | 360 | - (void)setBlurRadius:(CGFloat)blurRadius 361 | { 362 | _blurRadiusSet = YES; 363 | [self blurLayer].blurRadius = blurRadius; 364 | } 365 | 366 | - (CGFloat)blurRadius 367 | { 368 | return [self blurLayer].blurRadius; 369 | } 370 | 371 | - (void)setBlurEnabled:(BOOL)blurEnabled 372 | { 373 | _blurEnabledSet = YES; 374 | if (_blurEnabled != blurEnabled) 375 | { 376 | _blurEnabled = blurEnabled; 377 | [self schedule]; 378 | if (_blurEnabled) 379 | { 380 | [self setNeedsDisplay]; 381 | } 382 | } 383 | } 384 | 385 | - (void)setDynamic:(BOOL)dynamic 386 | { 387 | _dynamicSet = YES; 388 | if (_dynamic != dynamic) 389 | { 390 | _dynamic = dynamic; 391 | [self schedule]; 392 | if (!dynamic) 393 | { 394 | [self setNeedsDisplay]; 395 | } 396 | } 397 | } 398 | 399 | - (UIView *)underlyingView 400 | { 401 | return _underlyingView ?: self.superview; 402 | } 403 | 404 | - (CALayer *)underlyingLayer 405 | { 406 | return self.underlyingView.layer; 407 | } 408 | 409 | - (FXBlurLayer *)blurLayer 410 | { 411 | return (FXBlurLayer *)self.layer; 412 | } 413 | 414 | - (FXBlurLayer *)blurPresentationLayer 415 | { 416 | FXBlurLayer *blurLayer = [self blurLayer]; 417 | return (FXBlurLayer *)blurLayer.presentationLayer ?: blurLayer; 418 | } 419 | 420 | - (void)setUpdateInterval:(NSTimeInterval)updateInterval 421 | { 422 | _updateInterval = updateInterval; 423 | if (_updateInterval <= 0) _updateInterval = 1.0/60; 424 | } 425 | 426 | - (void)setTintColor:(UIColor *)tintColor 427 | { 428 | _tintColor = tintColor; 429 | [self setNeedsDisplay]; 430 | } 431 | 432 | - (void)didMoveToSuperview 433 | { 434 | [super didMoveToSuperview]; 435 | [self.layer setNeedsDisplay]; 436 | } 437 | 438 | - (void)didMoveToWindow 439 | { 440 | [super didMoveToWindow]; 441 | [self schedule]; 442 | } 443 | 444 | - (void)schedule 445 | { 446 | if (self.window && self.dynamic && self.blurEnabled) 447 | { 448 | [[FXBlurScheduler sharedInstance] addView:self]; 449 | } 450 | else 451 | { 452 | [[FXBlurScheduler sharedInstance] removeView:self]; 453 | } 454 | } 455 | 456 | - (void)setNeedsDisplay 457 | { 458 | [super setNeedsDisplay]; 459 | [self.layer setNeedsDisplay]; 460 | } 461 | 462 | - (BOOL)shouldUpdate 463 | { 464 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 465 | 466 | return 467 | underlyingLayer && !underlyingLayer.hidden && 468 | self.blurEnabled && [FXBlurScheduler sharedInstance].blurEnabled && 469 | !CGRectIsEmpty([self.layer.presentationLayer ?: self.layer bounds]) && !CGRectIsEmpty(underlyingLayer.bounds); 470 | } 471 | 472 | - (void)displayLayer:(__unused CALayer *)layer 473 | { 474 | [self updateAsynchronously:NO completion:NULL]; 475 | } 476 | 477 | - (id)actionForLayer:(CALayer *)layer forKey:(NSString *)key 478 | { 479 | if ([key isEqualToString:@"blurRadius"]) 480 | { 481 | //animations are enabled 482 | CAAnimation *action = (CAAnimation *)[super actionForLayer:layer forKey:@"bounds"]; 483 | if ((NSNull *)action != [NSNull null]) 484 | { 485 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key]; 486 | animation.fromValue = [layer.presentationLayer valueForKey:key]; 487 | animation.duration = action.duration; 488 | animation.timingFunction = action.timingFunction; 489 | animation.timeOffset = action.timeOffset; 490 | animation.delegate = action.delegate; 491 | return animation; 492 | } 493 | } 494 | return [super actionForLayer:layer forKey:key]; 495 | } 496 | 497 | - (UIImage *)snapshotOfUnderlyingView 498 | { 499 | __strong FXBlurLayer *blurLayer = [self blurPresentationLayer]; 500 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 501 | CGRect bounds = [blurLayer convertRect:blurLayer.bounds toLayer:underlyingLayer]; 502 | 503 | self.lastUpdate = [NSDate date]; 504 | CGFloat scale = 0.5; 505 | if (self.iterations) 506 | { 507 | CGFloat blockSize = 12.0f/self.iterations; 508 | scale = blockSize/MAX(blockSize * 2, blurLayer.blurRadius); 509 | scale = 1.0f/floorf(1.0f/scale); 510 | } 511 | CGSize size = bounds.size; 512 | if (self.contentMode == UIViewContentModeScaleToFill || 513 | self.contentMode == UIViewContentModeScaleAspectFill || 514 | self.contentMode == UIViewContentModeScaleAspectFit || 515 | self.contentMode == UIViewContentModeRedraw) 516 | { 517 | //prevents edge artefacts 518 | size.width = floorf(size.width * scale) / scale; 519 | size.height = floorf(size.height * scale) / scale; 520 | } 521 | else if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0f && [UIScreen mainScreen].scale == 1.0f) 522 | { 523 | //prevents pixelation on old devices 524 | scale = 1.0f; 525 | } 526 | UIGraphicsBeginImageContextWithOptions(size, YES, scale); 527 | CGContextRef context = UIGraphicsGetCurrentContext(); 528 | CGContextTranslateCTM(context, -bounds.origin.x, -bounds.origin.y); 529 | 530 | NSArray *hiddenViews = [self prepareUnderlyingViewForSnapshot]; 531 | [underlyingLayer renderInContext:context]; 532 | [self restoreSuperviewAfterSnapshot:hiddenViews]; 533 | UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); 534 | UIGraphicsEndImageContext(); 535 | return snapshot; 536 | } 537 | 538 | - (NSArray *)prepareUnderlyingViewForSnapshot 539 | { 540 | __strong CALayer *blurlayer = [self blurLayer]; 541 | __strong CALayer *underlyingLayer = [self underlyingLayer]; 542 | while (blurlayer.superlayer && blurlayer.superlayer != underlyingLayer) 543 | { 544 | blurlayer = blurlayer.superlayer; 545 | } 546 | NSMutableArray *layers = [NSMutableArray array]; 547 | NSUInteger index = [underlyingLayer.sublayers indexOfObject:blurlayer]; 548 | if (index != NSNotFound) 549 | { 550 | for (NSUInteger i = index; i < [underlyingLayer.sublayers count]; i++) 551 | { 552 | CALayer *layer = underlyingLayer.sublayers[i]; 553 | if (!layer.hidden) 554 | { 555 | layer.hidden = YES; 556 | [layers addObject:layer]; 557 | } 558 | } 559 | } 560 | return layers; 561 | } 562 | 563 | - (void)restoreSuperviewAfterSnapshot:(NSArray *)hiddenLayers 564 | { 565 | for (CALayer *layer in hiddenLayers) 566 | { 567 | layer.hidden = NO; 568 | } 569 | } 570 | 571 | - (UIImage *)blurredSnapshot:(UIImage *)snapshot radius:(CGFloat)blurRadius 572 | { 573 | return [snapshot blurredImageWithRadius:blurRadius 574 | iterations:self.iterations 575 | tintColor:self.tintColor]; 576 | } 577 | 578 | - (void)setLayerContents:(UIImage *)image 579 | { 580 | self.layer.contents = (id)image.CGImage; 581 | self.layer.contentsScale = image.scale; 582 | } 583 | 584 | - (void)updateAsynchronously:(BOOL)async completion:(void (^)())completion 585 | { 586 | if ([self shouldUpdate]) 587 | { 588 | UIImage *snapshot = [self snapshotOfUnderlyingView]; 589 | if (async) 590 | { 591 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 592 | 593 | UIImage *blurredImage = [self blurredSnapshot:snapshot radius:self.blurRadius]; 594 | dispatch_sync(dispatch_get_main_queue(), ^{ 595 | 596 | [self setLayerContents:blurredImage]; 597 | if (completion) completion(); 598 | }); 599 | }); 600 | } 601 | else 602 | { 603 | [self setLayerContents:[self blurredSnapshot:snapshot radius:[self blurPresentationLayer].blurRadius]]; 604 | if (completion) completion(); 605 | } 606 | } 607 | else if (completion) 608 | { 609 | completion(); 610 | } 611 | } 612 | 613 | @end 614 | -------------------------------------------------------------------------------- /OECentreMenuDemo/OECentreMenuDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4C95EA9F1AD1EAC300AEF79F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C95EA9E1AD1EAC300AEF79F /* main.m */; }; 11 | 4C95EAA21AD1EAC300AEF79F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C95EAA11AD1EAC300AEF79F /* AppDelegate.m */; }; 12 | 4C95EAA51AD1EAC300AEF79F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C95EAA41AD1EAC300AEF79F /* ViewController.m */; }; 13 | 4C95EAA81AD1EAC300AEF79F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C95EAA61AD1EAC300AEF79F /* Main.storyboard */; }; 14 | 4C95EAAA1AD1EAC300AEF79F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4C95EAA91AD1EAC300AEF79F /* Images.xcassets */; }; 15 | 4C95EAAD1AD1EAC300AEF79F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C95EAAB1AD1EAC300AEF79F /* LaunchScreen.xib */; }; 16 | 4C95EAB91AD1EAC300AEF79F /* OECentreMenuDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C95EAB81AD1EAC300AEF79F /* OECentreMenuDemoTests.m */; }; 17 | 4C95EAC41AD1EAF600AEF79F /* jiveScreenshot.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C95EAC31AD1EAF600AEF79F /* jiveScreenshot.png */; }; 18 | 4C95EACD1AD1EB0500AEF79F /* OECentreMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C95EAC71AD1EB0500AEF79F /* OECentreMenu.m */; }; 19 | 4C95EACE1AD1EB0500AEF79F /* FXBlurView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C95EACB1AD1EB0500AEF79F /* FXBlurView.m */; }; 20 | 4C95EACF1AD1EB0500AEF79F /* quaver.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C95EACC1AD1EB0500AEF79F /* quaver.png */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 4C95EAB31AD1EAC300AEF79F /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 4C95EA911AD1EAC300AEF79F /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 4C95EA981AD1EAC300AEF79F; 29 | remoteInfo = OECentreMenuDemo; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 4C95EA991AD1EAC300AEF79F /* OECentreMenuDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OECentreMenuDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 4C95EA9D1AD1EAC300AEF79F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 4C95EA9E1AD1EAC300AEF79F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | 4C95EAA01AD1EAC300AEF79F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 4C95EAA11AD1EAC300AEF79F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 4C95EAA31AD1EAC300AEF79F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 40 | 4C95EAA41AD1EAC300AEF79F /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 41 | 4C95EAA71AD1EAC300AEF79F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 4C95EAA91AD1EAC300AEF79F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43 | 4C95EAAC1AD1EAC300AEF79F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 44 | 4C95EAB21AD1EAC300AEF79F /* OECentreMenuDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OECentreMenuDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 4C95EAB71AD1EAC300AEF79F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 4C95EAB81AD1EAC300AEF79F /* OECentreMenuDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OECentreMenuDemoTests.m; sourceTree = ""; }; 47 | 4C95EAC31AD1EAF600AEF79F /* jiveScreenshot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = jiveScreenshot.png; sourceTree = ""; }; 48 | 4C95EAC61AD1EB0500AEF79F /* OECentreMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OECentreMenu.h; sourceTree = ""; }; 49 | 4C95EAC71AD1EB0500AEF79F /* OECentreMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OECentreMenu.m; sourceTree = ""; }; 50 | 4C95EACA1AD1EB0500AEF79F /* FXBlurView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FXBlurView.h; sourceTree = ""; }; 51 | 4C95EACB1AD1EB0500AEF79F /* FXBlurView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FXBlurView.m; sourceTree = ""; }; 52 | 4C95EACC1AD1EB0500AEF79F /* quaver.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = quaver.png; sourceTree = ""; }; 53 | /* End PBXFileReference section */ 54 | 55 | /* Begin PBXFrameworksBuildPhase section */ 56 | 4C95EA961AD1EAC300AEF79F /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | 4C95EAAF1AD1EAC300AEF79F /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 4C95EA901AD1EAC300AEF79F = { 74 | isa = PBXGroup; 75 | children = ( 76 | 4C95EA9B1AD1EAC300AEF79F /* OECentreMenuDemo */, 77 | 4C95EAB51AD1EAC300AEF79F /* OECentreMenuDemoTests */, 78 | 4C95EA9A1AD1EAC300AEF79F /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | 4C95EA9A1AD1EAC300AEF79F /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 4C95EA991AD1EAC300AEF79F /* OECentreMenuDemo.app */, 86 | 4C95EAB21AD1EAC300AEF79F /* OECentreMenuDemoTests.xctest */, 87 | ); 88 | name = Products; 89 | sourceTree = ""; 90 | }; 91 | 4C95EA9B1AD1EAC300AEF79F /* OECentreMenuDemo */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 4C95EAC51AD1EB0500AEF79F /* OECentreMenu */, 95 | 4C95EAC21AD1EAF600AEF79F /* Resources */, 96 | 4C95EAA01AD1EAC300AEF79F /* AppDelegate.h */, 97 | 4C95EAA11AD1EAC300AEF79F /* AppDelegate.m */, 98 | 4C95EAA31AD1EAC300AEF79F /* ViewController.h */, 99 | 4C95EAA41AD1EAC300AEF79F /* ViewController.m */, 100 | 4C95EAA61AD1EAC300AEF79F /* Main.storyboard */, 101 | 4C95EAA91AD1EAC300AEF79F /* Images.xcassets */, 102 | 4C95EAAB1AD1EAC300AEF79F /* LaunchScreen.xib */, 103 | 4C95EA9C1AD1EAC300AEF79F /* Supporting Files */, 104 | ); 105 | path = OECentreMenuDemo; 106 | sourceTree = ""; 107 | }; 108 | 4C95EA9C1AD1EAC300AEF79F /* Supporting Files */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 4C95EA9D1AD1EAC300AEF79F /* Info.plist */, 112 | 4C95EA9E1AD1EAC300AEF79F /* main.m */, 113 | ); 114 | name = "Supporting Files"; 115 | sourceTree = ""; 116 | }; 117 | 4C95EAB51AD1EAC300AEF79F /* OECentreMenuDemoTests */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 4C95EAB81AD1EAC300AEF79F /* OECentreMenuDemoTests.m */, 121 | 4C95EAB61AD1EAC300AEF79F /* Supporting Files */, 122 | ); 123 | path = OECentreMenuDemoTests; 124 | sourceTree = ""; 125 | }; 126 | 4C95EAB61AD1EAC300AEF79F /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 4C95EAB71AD1EAC300AEF79F /* Info.plist */, 130 | ); 131 | name = "Supporting Files"; 132 | sourceTree = ""; 133 | }; 134 | 4C95EAC21AD1EAF600AEF79F /* Resources */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 4C95EAC31AD1EAF600AEF79F /* jiveScreenshot.png */, 138 | ); 139 | path = Resources; 140 | sourceTree = ""; 141 | }; 142 | 4C95EAC51AD1EB0500AEF79F /* OECentreMenu */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 4C95EAC61AD1EB0500AEF79F /* OECentreMenu.h */, 146 | 4C95EAC71AD1EB0500AEF79F /* OECentreMenu.m */, 147 | 4C95EAC81AD1EB0500AEF79F /* Supporting */, 148 | ); 149 | path = OECentreMenu; 150 | sourceTree = ""; 151 | }; 152 | 4C95EAC81AD1EB0500AEF79F /* Supporting */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 4C95EAC91AD1EB0500AEF79F /* FXBlurView */, 156 | 4C95EACC1AD1EB0500AEF79F /* quaver.png */, 157 | ); 158 | path = Supporting; 159 | sourceTree = ""; 160 | }; 161 | 4C95EAC91AD1EB0500AEF79F /* FXBlurView */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 4C95EACA1AD1EB0500AEF79F /* FXBlurView.h */, 165 | 4C95EACB1AD1EB0500AEF79F /* FXBlurView.m */, 166 | ); 167 | path = FXBlurView; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXGroup section */ 171 | 172 | /* Begin PBXNativeTarget section */ 173 | 4C95EA981AD1EAC300AEF79F /* OECentreMenuDemo */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = 4C95EABC1AD1EAC300AEF79F /* Build configuration list for PBXNativeTarget "OECentreMenuDemo" */; 176 | buildPhases = ( 177 | 4C95EA951AD1EAC300AEF79F /* Sources */, 178 | 4C95EA961AD1EAC300AEF79F /* Frameworks */, 179 | 4C95EA971AD1EAC300AEF79F /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = OECentreMenuDemo; 186 | productName = OECentreMenuDemo; 187 | productReference = 4C95EA991AD1EAC300AEF79F /* OECentreMenuDemo.app */; 188 | productType = "com.apple.product-type.application"; 189 | }; 190 | 4C95EAB11AD1EAC300AEF79F /* OECentreMenuDemoTests */ = { 191 | isa = PBXNativeTarget; 192 | buildConfigurationList = 4C95EABF1AD1EAC300AEF79F /* Build configuration list for PBXNativeTarget "OECentreMenuDemoTests" */; 193 | buildPhases = ( 194 | 4C95EAAE1AD1EAC300AEF79F /* Sources */, 195 | 4C95EAAF1AD1EAC300AEF79F /* Frameworks */, 196 | 4C95EAB01AD1EAC300AEF79F /* Resources */, 197 | ); 198 | buildRules = ( 199 | ); 200 | dependencies = ( 201 | 4C95EAB41AD1EAC300AEF79F /* PBXTargetDependency */, 202 | ); 203 | name = OECentreMenuDemoTests; 204 | productName = OECentreMenuDemoTests; 205 | productReference = 4C95EAB21AD1EAC300AEF79F /* OECentreMenuDemoTests.xctest */; 206 | productType = "com.apple.product-type.bundle.unit-test"; 207 | }; 208 | /* End PBXNativeTarget section */ 209 | 210 | /* Begin PBXProject section */ 211 | 4C95EA911AD1EAC300AEF79F /* Project object */ = { 212 | isa = PBXProject; 213 | attributes = { 214 | LastUpgradeCheck = 0610; 215 | ORGANIZATIONNAME = "Odie Edo-Osagie"; 216 | TargetAttributes = { 217 | 4C95EA981AD1EAC300AEF79F = { 218 | CreatedOnToolsVersion = 6.1.1; 219 | }; 220 | 4C95EAB11AD1EAC300AEF79F = { 221 | CreatedOnToolsVersion = 6.1.1; 222 | TestTargetID = 4C95EA981AD1EAC300AEF79F; 223 | }; 224 | }; 225 | }; 226 | buildConfigurationList = 4C95EA941AD1EAC300AEF79F /* Build configuration list for PBXProject "OECentreMenuDemo" */; 227 | compatibilityVersion = "Xcode 3.2"; 228 | developmentRegion = English; 229 | hasScannedForEncodings = 0; 230 | knownRegions = ( 231 | en, 232 | Base, 233 | ); 234 | mainGroup = 4C95EA901AD1EAC300AEF79F; 235 | productRefGroup = 4C95EA9A1AD1EAC300AEF79F /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | 4C95EA981AD1EAC300AEF79F /* OECentreMenuDemo */, 240 | 4C95EAB11AD1EAC300AEF79F /* OECentreMenuDemoTests */, 241 | ); 242 | }; 243 | /* End PBXProject section */ 244 | 245 | /* Begin PBXResourcesBuildPhase section */ 246 | 4C95EA971AD1EAC300AEF79F /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 4C95EAA81AD1EAC300AEF79F /* Main.storyboard in Resources */, 251 | 4C95EAC41AD1EAF600AEF79F /* jiveScreenshot.png in Resources */, 252 | 4C95EAAD1AD1EAC300AEF79F /* LaunchScreen.xib in Resources */, 253 | 4C95EACF1AD1EB0500AEF79F /* quaver.png in Resources */, 254 | 4C95EAAA1AD1EAC300AEF79F /* Images.xcassets in Resources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | 4C95EAB01AD1EAC300AEF79F /* Resources */ = { 259 | isa = PBXResourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | /* End PBXResourcesBuildPhase section */ 266 | 267 | /* Begin PBXSourcesBuildPhase section */ 268 | 4C95EA951AD1EAC300AEF79F /* Sources */ = { 269 | isa = PBXSourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | 4C95EAA51AD1EAC300AEF79F /* ViewController.m in Sources */, 273 | 4C95EAA21AD1EAC300AEF79F /* AppDelegate.m in Sources */, 274 | 4C95EACE1AD1EB0500AEF79F /* FXBlurView.m in Sources */, 275 | 4C95EA9F1AD1EAC300AEF79F /* main.m in Sources */, 276 | 4C95EACD1AD1EB0500AEF79F /* OECentreMenu.m in Sources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | 4C95EAAE1AD1EAC300AEF79F /* Sources */ = { 281 | isa = PBXSourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | 4C95EAB91AD1EAC300AEF79F /* OECentreMenuDemoTests.m in Sources */, 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | /* End PBXSourcesBuildPhase section */ 289 | 290 | /* Begin PBXTargetDependency section */ 291 | 4C95EAB41AD1EAC300AEF79F /* PBXTargetDependency */ = { 292 | isa = PBXTargetDependency; 293 | target = 4C95EA981AD1EAC300AEF79F /* OECentreMenuDemo */; 294 | targetProxy = 4C95EAB31AD1EAC300AEF79F /* PBXContainerItemProxy */; 295 | }; 296 | /* End PBXTargetDependency section */ 297 | 298 | /* Begin PBXVariantGroup section */ 299 | 4C95EAA61AD1EAC300AEF79F /* Main.storyboard */ = { 300 | isa = PBXVariantGroup; 301 | children = ( 302 | 4C95EAA71AD1EAC300AEF79F /* Base */, 303 | ); 304 | name = Main.storyboard; 305 | sourceTree = ""; 306 | }; 307 | 4C95EAAB1AD1EAC300AEF79F /* LaunchScreen.xib */ = { 308 | isa = PBXVariantGroup; 309 | children = ( 310 | 4C95EAAC1AD1EAC300AEF79F /* Base */, 311 | ); 312 | name = LaunchScreen.xib; 313 | sourceTree = ""; 314 | }; 315 | /* End PBXVariantGroup section */ 316 | 317 | /* Begin XCBuildConfiguration section */ 318 | 4C95EABA1AD1EAC300AEF79F /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ALWAYS_SEARCH_USER_PATHS = NO; 322 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 323 | CLANG_CXX_LIBRARY = "libc++"; 324 | CLANG_ENABLE_MODULES = YES; 325 | CLANG_ENABLE_OBJC_ARC = YES; 326 | CLANG_WARN_BOOL_CONVERSION = YES; 327 | CLANG_WARN_CONSTANT_CONVERSION = YES; 328 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 329 | CLANG_WARN_EMPTY_BODY = YES; 330 | CLANG_WARN_ENUM_CONVERSION = YES; 331 | CLANG_WARN_INT_CONVERSION = YES; 332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 333 | CLANG_WARN_UNREACHABLE_CODE = YES; 334 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 335 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 336 | COPY_PHASE_STRIP = NO; 337 | ENABLE_STRICT_OBJC_MSGSEND = YES; 338 | GCC_C_LANGUAGE_STANDARD = gnu99; 339 | GCC_DYNAMIC_NO_PIC = NO; 340 | GCC_OPTIMIZATION_LEVEL = 0; 341 | GCC_PREPROCESSOR_DEFINITIONS = ( 342 | "DEBUG=1", 343 | "$(inherited)", 344 | ); 345 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 346 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 347 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 348 | GCC_WARN_UNDECLARED_SELECTOR = YES; 349 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 350 | GCC_WARN_UNUSED_FUNCTION = YES; 351 | GCC_WARN_UNUSED_VARIABLE = YES; 352 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 353 | MTL_ENABLE_DEBUG_INFO = YES; 354 | ONLY_ACTIVE_ARCH = YES; 355 | SDKROOT = iphoneos; 356 | }; 357 | name = Debug; 358 | }; 359 | 4C95EABB1AD1EAC300AEF79F /* Release */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | ALWAYS_SEARCH_USER_PATHS = NO; 363 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 364 | CLANG_CXX_LIBRARY = "libc++"; 365 | CLANG_ENABLE_MODULES = YES; 366 | CLANG_ENABLE_OBJC_ARC = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_CONSTANT_CONVERSION = YES; 369 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 370 | CLANG_WARN_EMPTY_BODY = YES; 371 | CLANG_WARN_ENUM_CONVERSION = YES; 372 | CLANG_WARN_INT_CONVERSION = YES; 373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 374 | CLANG_WARN_UNREACHABLE_CODE = YES; 375 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 376 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 377 | COPY_PHASE_STRIP = YES; 378 | ENABLE_NS_ASSERTIONS = NO; 379 | ENABLE_STRICT_OBJC_MSGSEND = YES; 380 | GCC_C_LANGUAGE_STANDARD = gnu99; 381 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 382 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 383 | GCC_WARN_UNDECLARED_SELECTOR = YES; 384 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 385 | GCC_WARN_UNUSED_FUNCTION = YES; 386 | GCC_WARN_UNUSED_VARIABLE = YES; 387 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 388 | MTL_ENABLE_DEBUG_INFO = NO; 389 | SDKROOT = iphoneos; 390 | VALIDATE_PRODUCT = YES; 391 | }; 392 | name = Release; 393 | }; 394 | 4C95EABD1AD1EAC300AEF79F /* Debug */ = { 395 | isa = XCBuildConfiguration; 396 | buildSettings = { 397 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 398 | INFOPLIST_FILE = OECentreMenuDemo/Info.plist; 399 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | }; 402 | name = Debug; 403 | }; 404 | 4C95EABE1AD1EAC300AEF79F /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 408 | INFOPLIST_FILE = OECentreMenuDemo/Info.plist; 409 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | }; 412 | name = Release; 413 | }; 414 | 4C95EAC01AD1EAC300AEF79F /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | BUNDLE_LOADER = "$(TEST_HOST)"; 418 | FRAMEWORK_SEARCH_PATHS = ( 419 | "$(SDKROOT)/Developer/Library/Frameworks", 420 | "$(inherited)", 421 | ); 422 | GCC_PREPROCESSOR_DEFINITIONS = ( 423 | "DEBUG=1", 424 | "$(inherited)", 425 | ); 426 | INFOPLIST_FILE = OECentreMenuDemoTests/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OECentreMenuDemo.app/OECentreMenuDemo"; 430 | }; 431 | name = Debug; 432 | }; 433 | 4C95EAC11AD1EAC300AEF79F /* Release */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | BUNDLE_LOADER = "$(TEST_HOST)"; 437 | FRAMEWORK_SEARCH_PATHS = ( 438 | "$(SDKROOT)/Developer/Library/Frameworks", 439 | "$(inherited)", 440 | ); 441 | INFOPLIST_FILE = OECentreMenuDemoTests/Info.plist; 442 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OECentreMenuDemo.app/OECentreMenuDemo"; 445 | }; 446 | name = Release; 447 | }; 448 | /* End XCBuildConfiguration section */ 449 | 450 | /* Begin XCConfigurationList section */ 451 | 4C95EA941AD1EAC300AEF79F /* Build configuration list for PBXProject "OECentreMenuDemo" */ = { 452 | isa = XCConfigurationList; 453 | buildConfigurations = ( 454 | 4C95EABA1AD1EAC300AEF79F /* Debug */, 455 | 4C95EABB1AD1EAC300AEF79F /* Release */, 456 | ); 457 | defaultConfigurationIsVisible = 0; 458 | defaultConfigurationName = Release; 459 | }; 460 | 4C95EABC1AD1EAC300AEF79F /* Build configuration list for PBXNativeTarget "OECentreMenuDemo" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | 4C95EABD1AD1EAC300AEF79F /* Debug */, 464 | 4C95EABE1AD1EAC300AEF79F /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | }; 468 | 4C95EABF1AD1EAC300AEF79F /* Build configuration list for PBXNativeTarget "OECentreMenuDemoTests" */ = { 469 | isa = XCConfigurationList; 470 | buildConfigurations = ( 471 | 4C95EAC01AD1EAC300AEF79F /* Debug */, 472 | 4C95EAC11AD1EAC300AEF79F /* Release */, 473 | ); 474 | defaultConfigurationIsVisible = 0; 475 | }; 476 | /* End XCConfigurationList section */ 477 | }; 478 | rootObject = 4C95EA911AD1EAC300AEF79F /* Project object */; 479 | } 480 | --------------------------------------------------------------------------------