开发者

How to properly insert a background image

I use this code to set a background image. The only problem is that it covers everything I insert in the XIB file. What should I do to ensure that my textfields, buttons, etc. are also visible (in front of the backgr开发者_StackOverflowound). Thanks for your help!

// Setup the background
UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.view addSubview:background];
[background release];


UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]]; [self.view addSubview:background]; [self sendSubviewToBack:background]; [background release];


If you are using an XIB, then just make sure that all of your objects are above the UIImageView.

Alternatively, you can use colorWithPatternImage:

UIImage * bg = [UIImage imageNamed:@"bg.png"];
[myView_ setBackgroundColor:[UIColor colorWithPatternImage: bg]];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜