在 iOS 的表格视图单元格中更改披露指示器附件视图的颜色/视图的最佳方法是什么? [英] Which is the best way to change the color/view of disclosure indicator accessory view in a table view cell in iOS?

查看:21
本文介绍了在 iOS 的表格视图单元格中更改披露指示器附件视图的颜色/视图的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改 UITableViewCelldisclosureIndicatorView 附件的颜色.我认为有两种方法可以完成这项工作,但我无法确定哪种方法是最佳的.所以这就是我认为我能做的.

I need to change the color of the disclosureIndicatorView accessory in a UITableViewCell. I think there are two ways to get this done, but I'm not able to figure out which one's the optimum. So here is what I think I can do.

UITableViewCell 有一个属性 - accessoryView.所以我可以使用 setAccessoryView:(UIView *)view 并将视图作为 UIImageView 传递给我想要的图像.

There is a property of UITableViewCell - accessoryView. So I can use setAccessoryView:(UIView *)view and pass view as the UIImageView holding the image that I want.

我编写了一个实用程序类,它为我的单元格创建内容视图(如背景颜色、添加其他内容等),并将此内容视图添加到 UITableViewDelegate 中的单元格.另一种选择是绘制一个 UIImage 覆盖 CustomContentView 实用程序类的 drawRect 方法.

I have written an utility class which creates the content view (stuff like background color, adding other stuff, etc) for my cell and I add this content view to the cell in UITableViewDelegate. The other option is to draw a UIImage overriding the drawRect method of CustomContentView utility class.

执行选项 1 - 我可以像苹果一样完成工作.只给他们观点,剩下的交给他们.但我想向每一行添加一个新的 UIView 对象可能会导致大量的对象分配并降低帧速率.与我的 contentView 中的 UIImage 对象相比.我相信 UIImageUIView 更轻.

Performing option 1 - I can get the things done the apple way. Just give them the view and they do the rest. But I guess adding a new UIView object to every row might turn out to be a heavy object allocation and decreasing the frame rate. As compared to just a UIImage object in my contentView. I believe UIImage is lighter than UIView.

请让一些轻松的人帮我决定.

Please throw some light people and help me decide over it.

推荐答案

但我想向每一行添加一个新的 UIView 对象可能会导致大量的 obj 分配并降低帧速率.与我的 contentView 中的 UIImage 对象相比.我相信 UIImage 比 UIView 轻.

But I guess adding a new UIView object to every row might turn out to be a heavy obj allocation and decreasing the frame rate. As compared to just a UIImage object in my contentView. I believe UIImage is lighter than UIView.

直接绘制图像几乎肯定比添加子视图具有更好的性能.您必须确定是否需要额外的性能.我在基本单元格上使用了一些辅助视图来自定义披露指标,性能很好.但是,如果您已经在为内容 rect 进行自定义绘图,那么也可能不会那么难做附件视图.

Drawing an image directly will almost certainly have better performance than adding a subview. You have to determine if that extra performance is necessary. I've used a few accessory views for custom disclosure indicators on basic cells and performance was fine. However, if you're already doing custom drawing for the content rect, it might not be that difficult to do the accessory view also.

这篇关于在 iOS 的表格视图单元格中更改披露指示器附件视图的颜色/视图的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆