一个简短的问题,我想将UITableViewCellAccessoryDisclosureIndicator
(tableView
右侧的箭头)的颜色从默认灰色更改为白色。更改UITableViewCellAccessoryDisclosureIndicator的颜色
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
一个简短的问题,我想将UITableViewCellAccessoryDisclosureIndicator
(tableView
右侧的箭头)的颜色从默认灰色更改为白色。更改UITableViewCellAccessoryDisclosureIndicator的颜色
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
您应该创建一个图像,然后使用它!
cell。 accessoryView = myAccessoryUIImageView;
是任何方式来更改iphone中的UITableViewCellAccessoryDisclosureIndicato颜色默认 – kingston 2011-05-17 06:09:40
我怀疑是可以更改默认情况下。你可以继承UITableViewCell并自定义所有的,也许可以在其他地方重用吗? – prakash 2011-05-17 06:19:55
**可以为原始苹果指示器着色:**请参阅我的回答:http://stackoverflow.com/a/35427683/378024 (不使用自定义图像或自定义绘图代码) – galambalazs 2016-02-16 08:58:52
对于其他人谁正在就这个问题仍然磕磕绊绊,这里是如何做到这一点编程。
创建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);
}
这绘制股票指示箭头。从这里你可以改变颜色,线宽等
到指示器视图添加到您的细胞:
#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)];
要改变的UITableViewCellAccessoryDetailDisclosureButton
颜色:
cell.tintColor = [UIColor whiteColor];
这里是唯一正确的答案。 – Andy 2014-02-09 17:36:32
答案可能是“正确的”,但它可悲地不回答被问到的问题。 UITableViewCellAccessoryDisclosureIndicator与UITableViewCellAccessoryDetailDisclosureButton不一样。 :( – 2014-03-18 19:40:06
UITableViewCell没有这种方法tintColor – 2014-09-20 10:34:22
你发现包括MSCellAccessory将有助于许多不同的方式,包括更改UITableViewCellAccessoryDetailDisclosureButton的颜色
旧的问题,但没有满意的答案呢。这里是你*实际*要求:http://stackoverflow.com/a/35427683/378024 – galambalazs 2016-02-16 08:59:14