don*_*ile 1 iphone uitableview
我试图在自定义UITableViewCell子类中覆盖-selectedBackgroundView的访问器.但是,当选择单元格时,单元格将继续使用默认的蓝色选择背景.怎么改变?
我真的很确定这个蓝色选择的东西是selectedBackgroundView ......还有什么应该负责这个有浅色渐变的蓝色背景?奇怪的是,contentView就在那之上,虽然它有一个除了[UIColor clearColor]之外的backgroundColor,但是这个selectedBackgroundView似乎仍然闪耀着.真奇怪.
你必须把这个代码放入"cellForRowAtIndexPath"
要禁用单元格选择:(单击单元格时)
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)
用于启用单元格:(在单击单元格时)
cell.selectionStyle = UITableViewCellSelectionStyleBlue;(By Default)
cell.selectionStyle = UITableViewCellSelectionStyleGray;
Run Code Online (Sandbox Code Playgroud)
如果你想提供自定义颜色,那么在cellForRowAtIndexPath中"
if (cell==nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
UIView *v = [[[UIView alloc] init] autorelease];
v.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = v;
}
Run Code Online (Sandbox Code Playgroud)
祝一切顺利.
| 归档时间: |
|
| 查看次数: |
612 次 |
| 最近记录: |