我可以使用突出显示表格视图单元格而没有目标c中的默认蓝色吗? [英] can i use highlighted the table view cell without default blue color in objective c?
本文介绍了我可以使用突出显示表格视图单元格而没有目标c中的默认蓝色吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个项目,我需要使用突出显示的表视图颜色而不是默认颜色。
I doing a project where i need to use highlighted table view color not default.
推荐答案
当然可以。
有两种方法可以达到此目的:
There are two methods to achieve this:
- 使用
UITableViewCell
的selectedBackgroundView
和selectedTextColor
属性 - 子类
UITableViewCell
并实施drawInRect
和setSelected:animated:
methods
- Use
UITableViewCell
'sselectedBackgroundView
andselectedTextColor
properties - Subclass
UITableViewCell
and implement thedrawInRect
andsetSelected:animated:
methods
后一个选项为您提供了更大的灵活性和更好的性能,但如果您之前没有使用过CoreGraphics,可能会稍微困难一些。
The latter option gives you more flexibility and much better performance, but it might be slightly harder if you haven't used CoreGraphics before.
UPDATE 响应OP的评论:
以下是如何使用 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.
这篇关于我可以使用突出显示表格视图单元格而没有目标c中的默认蓝色吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文