【原】给UIview添加背景图片最简单方法
在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];
- }