xcode 更改 UITableViewCellAccessoryDisclosureIndicator 的颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6026822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change the color of UITableViewCellAccessoryDisclosureIndicator
提问by kingston
A quick question, I want to change the color of the UITableViewCellAccessoryDisclosureIndicator
(the arrow on the right side of tableView
) from default gray to white color.
一个快速的问题,我想将UITableViewCellAccessoryDisclosureIndicator
(右侧的箭头tableView
)的颜色从默认的灰色更改为白色。
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
回答by prakash
You should create an image and use it instead!
您应该创建一个图像并使用它!
cell. accessoryView = myAccessoryUIImageView;
细胞。附件视图 = myAccessoryUIImageView;
回答by Naloiko Eugene
To change the colour of UITableViewCellAccessoryDetailDisclosureButton
:
要更改 的颜色UITableViewCellAccessoryDetailDisclosureButton
:
cell.tintColor = [UIColor whiteColor];
回答by RobCroll
You'll find including MSCellAccessorywill help in a lot of different ways including changing the color of the UITableViewCellAccessoryDetailDisclosureButton
你会发现包括MSCellAccessory将在很多不同的方面有所帮助,包括改变 UITableViewCellAccessoryDetailDisclosureButton 的颜色
回答by Anthony
For others who are still stumbling upon this question, here's how to do it programmatically.
对于仍然在这个问题上磕磕绊绊的其他人,这里是如何以编程方式做到这一点。
Create a UIView subclass, and override drawRect:
with the following:
创建一个 UIView 子类,并drawRect:
使用以下内容覆盖:
#define PADDING 4.f //give the canvas some padding so the ends and joints of the lines can be drawn with a mitered joint
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor grayColor].CGColor);
CGContextSetLineWidth(context, 3.f);
CGContextSetLineJoin(context, kCGLineJoinMiter);
CGContextMoveToPoint(context, PADDING, PADDING);
CGContextAddLineToPoint(context, self.frame.size.width - PADDING, self.frame.size.height/2);
CGContextAddLineToPoint(context, PADDING, self.frame.size.height - PADDING);
CGContextStrokePath(context);
}
This draws a stock indicator arrow. From here you can change the color, line width, etc.
这将绘制一个股票指标箭头。从这里您可以更改颜色、线宽等。
To add the indicator view to your cell:
要将指示器视图添加到您的单元格:
#define ACCESSORY_WIDTH 13.f
#define ACCESSORY_HEIGHT 18.f
cell.accessoryView = [[AccessoryIndicatorView alloc] initWithFrame:CGRectMake(self.frame.size.width - ACCESSORY_WIDTH - CELL_PADDING, self.frame.size.height/2 - ACCESSORY_HEIGHT/2, ACCESSORY_WIDTH, ACCESSORY_HEIGHT)];
回答by Francois Robert
As mentioned on: Which is the best way to change the color/view of disclosure indicator accessory view in a table view cell in iOS?
如上所述:在 iOS 的表视图单元格中更改披露指示器附件视图的颜色/视图的最佳方法是什么?
A complete implementation is available at: http://www.cocoanetics.com/2010/10/custom-colored-disclosure-indicators/
完整的实现可在:http: //www.cocoanetics.com/2010/10/custom-colored-disclosure-indicators/