5

I have a custom tableviewcell with the standard disclosure indicator positioned in the centre vertically by default. How can I move this standard disclosure indicator vertically like in the iOS mail app?

enter image description here

Moin Shirazi
  • 4,372
  • 2
  • 26
  • 38
spigen
  • 161
  • 2
  • 9

3 Answers3

16

You can adjust the position of the default accessory by subclassing your cell and finding the UIButton in the cell's subviews (which represents the indicator) and holding a reference to it. You can then simply update the frame of the accessoryButton in layoutSubviews or wherever you choose like so:

class CellSubclass: UITableViewCell {

    var accessoryButton: UIButton?

    override func awakeFromNib() {
        super.awakeFromNib()
        accessoryType = .DisclosureIndicator
        accessoryButton = subviews.flatMap { $0 as? UIButton }.first
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        accessoryButton?.frame.origin.y = 8
    }
}
Ian
  • 12,538
  • 5
  • 43
  • 62
1

You can not move standard disclosure indicator vertically.

If you want to achieve this functionality, then you need to use your custom cell and use image of disclosure indicator and then you can set this image with button on where ever you want to place.

Or you can use view also as a accessory indicator and add as a subview of UITableViewCell

[cell.contentView addSubview:aView];

You can read more over here disclosure indicator

Community
  • 1
  • 1
Nik
  • 1,679
  • 1
  • 20
  • 36
1

You can modify the Layout Margins to Fixed on TableViewCell in the .xib and then set the right margin to the desired value.

Zoli
  • 41
  • 1
  • 7