UITableViewCellの背景を透過する

UITableViewCellの背景を透過する、あるいは消す方法。
UITableViewCellのbackgroundViewに新しい空のUIViewを設定し、選択された時の色をなくせばいい。

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
	cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
	[cell setBackgroundView:[[[UIView alloc] init] autorelease]];
	[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
return cell;

よく使うのにどうやってやるのか不安げになりがちなのでメモ。

Pocket
LINEで送る
LinkedIn にシェア