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

查看:123
本文介绍了在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.

几乎可以肯定,直接绘制图像比添加子视图具有更好的性能.您必须确定是否需要额外的性能.我已经使用了一些辅助视图,用于基本单元的自定义公开指示器,并且性能还不错.但是,如果您已经在为内容矩形进行自定义绘制,则进行附件视图可能并不那么困难.

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天全站免登陆