在viewDidLoad里面添加:
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"11.jpg"]]];
就是这么简单
也可以另设一个UIImageView,把图片放上去,再把UIImageView 作为子视图添加上去:
- - (void)setBackgroundImage {
- NSLog(@"setting bg image");
- UIImageView *customBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];
- self.background = customBackground;
- [customBackground release];
- [self addSubview:background];
- NSLog(@"Added background subview %@", background);
- [self sendSubviewToBack:background];
- }
本文转自编程小翁博客园博客,原文链接:http://www.cnblogs.com/wengzilin/archive/2012/03/18/2404592.html,如需转载请自行联系原作者