开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜