开发者

Custom background image set up in main.m that is used in the whole app?

开发者 https://www.devze.com 2023-04-03 05:02 出处:网络
How can I add a custom image (or hex color) to main.m that will be used in the whole application and all it\'s views开发者_StackOverflow?Don\'t set it up in the main.m. Use your AppDelegate for that.

How can I add a custom image (or hex color) to main.m that will be used in the whole application and all it's views开发者_StackOverflow?


Don't set it up in the main.m. Use your AppDelegate for that. A solution could look like this:

YourAppDelegate.h

YourAppDelegate : UIApplication <UIResponder> {
      UIImageView *myGlobalBackgroundImage;
}

@property (nonatomic, retain) UIImageView *myGlobalBackgroundImage;

YourAppDelegate.m

@implementation YourAppDelegate
@synthesize myGlobalBackgroundImage;

-.....applicationDidFinishLaunching....{
     myGlobalBackgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imagefilename.ext"]];
}

Then grab that ivar from within your UIViewController and add it as a subview in the viewDidLoad method.

0

精彩评论

暂无评论...
验证码 换一张
取 消