Reputation: 681
I can't change the default Accessory Type->Disclosure Indicator view
's color in my UItableviewCell.
When I change tableviewcell tint color, it changes the following Accessory Type view color.
But I can't change the "Disclosure Indicator" color.
Do you have any other option to change 'Disclosure Indicator' color other than to set image in accessory view?
Screenshots:
Upvotes: 3
Views: 4716
Reputation: 5213
You can put your image in accessoryView
and your problem solved.
Sample Code
Put this code in cellForRowAtIndexPath
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 11, 22, 22)];
imgView.contentMode = UIViewContentModeScaleAspectFit;
imgView.image = [UIImage imageNamed:@"IconMore"];
cell.accessoryView = imgView;
Upvotes: 2
Reputation: 6555
Apple does not provide any option for this, you can do by creating custom UIView. Please find below custom View for the same,
import UIKit
class CustomDisclosureIndicator: UIView {
@IBInspectable
public var color: UIColor = UIColor.darkGray {
didSet {
setNeedsDisplay()
}
}
override func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
let x = self.bounds.maxX - 3
let y = self.bounds.midY
let R = CGFloat(4.5)
context?.move(to: CGPoint(x: x-R, y: y-R))
context?.addLine(to: CGPoint(x: x, y: y))
context?.addLine(to: CGPoint(x: x-R, y: y+R))
context?.setLineCap(.square)
context?.setLineJoin(.miter)
context?.setLineWidth(2)
color.setStroke()
context?.strokePath()
}
}
You can do following way,
Above code produces following output.
Try it once and let me know if any other queries are there.
Upvotes: 0