UITableView - 突出显示所选单元格[iOS]

Pau*_*ris 10 iphone xcode objective-c uitableview ios4

我已经创建了一个自定义TableCell的UITableView,通常遵循本教程;

http://www.theappcodeblog.com/?p=353

我根据自己的需求定制了它,看起来很棒.但是,当我选择一行时,它会通过将整个事物更改为蓝色来突出显示该行.这个亮点涵盖了整个单元格并覆盖了内容,有效地制作了一个看起来很讨厌的大蓝盒子.我已经尝试了备用突出显示选项

cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
Run Code Online (Sandbox Code Playgroud)

显然,如果选择为灰色,则会出现相同的行为,但会出现灰色的丑陋框."无"是最好的选择,但不能为我的用户提供良好的体验,因为我想表明他们选择了那一行.

任何人都可以建议一种方法来显示该行是高亮的,但仍然显示下面的文字?半透明度?

谢谢

xuz*_*zhe 11

也许是因为您的示例代码设置为:

artistLabel.highlightedTextColor = [UIColor clearColor];.

当高亮显示时,它会使artistLabel的文字颜色变得透明.

因为您可以为标签的highlightTextColor属性设置自己的颜色,例如:

[UIColor whiteColor]


小智 8

UITableView Cell选择了Color

请享用...

// Image
UIImage *selectionBackground = [UIImage imageNamed:@"g7.png"];
UIImageView *bgview=[[UIImageView alloc] initWithImage:selectionBackground];
cell.selectedBackgroundView=bgview;
[bgview release];
Run Code Online (Sandbox Code Playgroud)

要么

// Color
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor brownColor]];
[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];
Run Code Online (Sandbox Code Playgroud)


Vij*_*com 5

您可以使用自己的自定义视图进行选择

这里我有绿色视图。像这样你可以改变你想要的任何定制。

if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithFrame: CGRectZero 
                                   reuseIdentifier: CellIdentifier] autorelease];


    UIView *selectionView = [[UIView alloc]initWithFrame:cell.bounds];

    [selectionView setBackgroundColor:[UIColor greenColor]];

    cell.selectedBackgroundView = selectionView;


    [selectionView release];

}
Run Code Online (Sandbox Code Playgroud)