[英]can i use highlighted the table view cell without default blue color in objective c?
我在一个项目中需要使用突出显示的表格视图颜色,而不是默认颜色。
Of course you can. 当然可以。
There are two methods to achieve this: 有两种方法可以实现此目的:
UITableViewCell
's selectedBackgroundView
and selectedTextColor
properties UITableViewCell
的selectedBackgroundView
和selectedTextColor
属性 UITableViewCell
and implement the drawInRect
and setSelected:animated:
methods UITableViewCell
并实现drawInRect
和setSelected:animated:
方法 The latter option gives you more flexibility and much better performance, but it might be slightly harder if you haven't used CoreGraphics before. 后一个选项为您提供了更大的灵活性和更好的性能,但是如果您以前没有使用CoreGraphics,则可能会更难。
UPDATE In response to the OP's comment: 更新针对OP的评论:
Here's how you can use the selectedBackgroundView
property: 这是如何使用
selectedBackgroundView
属性的方法:
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
[bgView setBackgroundColor:[UIColor redColor]];
[cell setSelectedBackgroundView:bgView];
[bgView release];
I haven't tried this myself, but it should work. 我自己没有尝试过,但是应该可以。
尝试参考此演示 -也许您可以看一下并获得一些帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.