Sealyu

--- 博客已迁移至: http://www.sealyu.com/blog

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  618 随笔 :: 87 文章 :: 225 评论 :: 0 Trackbacks
方法一,使用一个UIImageView实例做子视图,并且放最后面

Objective-c代码
  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];  
  10. }  


方法二,Cook Book中提到的方法

Objective-c代码
  1. - (void)loadView {  
  2.       
  3.     UIImageView *contentView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];  
  4.     [contentView setImage:[UIImage imageNamed:@"Default.png"]];  
  5.     [contentView setUserInteractionEnabled:YES];  
  6.     self.view = contentView;  
  7.     [contentView release];  
  8. }  


方法三,lvyile网友用的一个小技巧,uiView是UIView的实例,而不是UIImageView

Objective-c代码
  1. uiView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]]; 
posted on 2010-10-08 16:04 seal 阅读(1089) 评论(0)  编辑  收藏 所属分类: iPhone

只有注册用户登录后才能发表评论。


网站导航: