在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];
- }
