2011年7月20日水曜日

【メモ】UITableViewの背景に画像を利用する。

iPhoneアプリの作り方を勉強中。
UITableViewの背景に画像を使う方法がわからなくて
いろいろ挑戦してみたら、下の方法を利用するとうまくいった。

UITableVIewの背景を透明化してから背景をはめ込むイメージかんじなのかな?


  1. - (void)viewDidLoad {  
  2.    [super viewDidLoad];  
  3.   
  4.    //リストの背景透明化  
  5.    [self.tableView setBackgroundView:nil];  
  6.    [self.tableView setBackgroundView:[[[UIView alloc] init] autorelease]];  
  7.    self.tableView.backgroundColor = [UIColor clearColor];  
  8.   
  9.    //背景画像指定  
  10.    UIColor *col = [[UIColor alloc]   
  11.            initWithPatternImage:[UIImage imageNamed:@"background.jpg"]];  
  12.    [self.tableView setBackgroundColor:col];  
  13.    [col release];  
  14. }  

0 件のコメント:

コメントを投稿