Created
March 20, 2016 13:15
-
-
Save jaygarcia/c70e7285a013ec44ff57 to your computer and use it in GitHub Desktop.
Set iOS lowest most view background to an image for ReactNative.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation | |
moduleName:@"GORUCK" | |
initialProperties:nil | |
launchOptions:launchOptions]; | |
// JG: Configure the scaled image for the background | |
CGRect bounds =[UIScreen mainScreen].bounds; | |
UIGraphicsBeginImageContext(bounds.size); | |
[[UIImage imageNamed:@"goruck_wallpaper"] drawInRect:bounds]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
self.window = [[UIWindow alloc] initWithFrame:bounds]; | |
// JG: Set the background image | |
self.window.backgroundColor = [UIColor colorWithPatternImage:image]; | |
// JG: Set the rootView background color to opaque | |
rootView.backgroundColor = [UIColor colorWithWhite:0 alpha:0]; | |
UIViewController *rootViewController = [UIViewController new]; | |
rootViewController.view = rootView; | |
self.window.rootViewController = rootViewController; | |
[self.window makeKeyAndVisible]; | |
// http://moduscreate.com | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing, I'm using this snippet thou I get a stretched image. Is there a way to set the width?