How to change UITableViewRowAction title color?

后端 未结 10 879
梦如初夏
梦如初夏 2020-11-30 05:49

Am using UITableViewRowAction in \"editActionsForRowAtIndexPath\" method. I can change the backgroundcolor of UITableViewRowAction, but am not able to change the title color

10条回答
  •  爱一瞬间的悲伤
    2020-11-30 06:43

    Swift

    No need to mess with UIButton.appearance...

    Put this in your cell's class and change UITableViewCellActionButton according to your needs.

    override func layoutSubviews() {
    
        super.layoutSubviews()
    
        for subview in self.subviews {
    
            for subview2 in subview.subviews {
    
                if (String(subview2).rangeOfString("UITableViewCellActionButton") != nil) {
    
                    for view in subview2.subviews {
    
                        if (String(view).rangeOfString("UIButtonLabel") != nil) {
    
                            if let label = view as? UILabel {
    
                                label.textColor = YOUR COLOUR
                            }
    
                        }
                    }
                }
            }
        }
    
    }
    

提交回复
热议问题