2011年06月19日

TableViewのBackgroundにimageを表示する

UITableViewの背景に画像を表示する方法。

1. UITableViewCellのセルに背景画像を表示する。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [self._listitemTable dequeueReusableCellWithIdentifier:@"HogeViewCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"HogeViewCell"] autorelease];

UIColor *col = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"backupgroundTableCell.png"]];
[tableView setBackgroundColor:col];
[col release];

}



2. Viewの背景として画像を表示する。
- (void)viewDidLoad {
[super viewDidLoad];

UIImageView *backImageview = [[[UIImageView alloc] initWithFrame:self.view.bounds] autorelease];
[backImageview setImage:[UIImage imageNamed:@"backupground.png"]];
[self.view addSubview:backImageview];



上記1.の場合、セルに表示されるデータがない場合は背景画像が表示されないが、上記2.の場合はViewが表示されたときに背景画像も表示される。

ラベル:iPhone
posted by mobileDeveloper at 12:54 | Comment(0) | TrackBack(0) | UITableView | このブログの読者になる | 更新情報をチェックする
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

認証コード: [必須入力]


※画像の中の文字を半角で入力してください。
※ブログオーナーが承認したコメントのみ表示されます。

この記事へのトラックバック