TableViewCell 披露指示器位置 [英] TableViewCell disclosure indicator position

查看:20
本文介绍了TableViewCell 披露指示器位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的tableviewcell,标准显示指示器默认位于垂直中心.如何像在 iOS 邮件应用中一样垂直移动这个标准披露指示器?

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?

推荐答案

你可以调整默认附件的位置.然后,您可以简单地在 layoutSubviews 或您选择的任何位置更新附件按钮的框架:

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
    }
}

这篇关于TableViewCell 披露指示器位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆