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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:02:48  来源:igfitidea点击:

Change the color of UITableViewCellAccessoryDisclosureIndicator

objective-cxcodeuitableview

提问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将在很多不同的方面有所帮助,包括改变 UITableViewCellAccessoryDe​​tailDisclosureButton 的颜色

回答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)];