在viewDidLoad里面添加:  

[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"11.jpg"]]];

就是这么简单

 

也可以另设一个UIImageView,把图片放上去,再把UIImageView 作为子视图添加上去:

  1. - (void)setBackgroundImage {  
  2.     NSLog(@"setting bg image");  
  3.     UIImageView *customBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];  
  4.     self.background = customBackground;  
  5.     [customBackground release];  
  6.       
  7.     [self addSubview:background];  
  8.     NSLog(@"Added background subview %@", background);  
  9.     [self sendSubviewToBack:background];  

相关文章:

  • 2022-12-23
  • 2021-10-28
  • 2021-12-04
  • 2021-05-20
  • 2022-01-18
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-10-18
  • 2021-12-31
  • 2022-12-23
相关资源
相似解决方案