Copyright (C) iPhoneアプリ開発備忘録 All rights reserved.
ブログ内で記したコード、内容の正確性は保証いたしません。
記載内容を実装したことにより発生した不具合・損害等の責任は一切負いません。



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 はてなブックマーク - TableViewのBackgroundにimageを表示する | このブログの読者になる | 更新情報をチェックする
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

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


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

この記事へのトラックバック
Apple、Appleのロゴ、App Store、iPodのロゴ、iTunesは、米国および他国のApple Inc.の登録商標です。
iPhone、iPod touch、iPadはApple Inc.の商標です。
iPhone商標は、アイホン株式会社のライセンスに基づき使用されています。
その他、本ブログに記載されている製品名、会社名は、それぞれ各社の商標または登録商標です。
×

この広告は90日以上新しい記事の投稿がないブログに表示されております。