How to change UITableViewRowAction title color?

后端 未结 10 863
梦如初夏
梦如初夏 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:34

    Lee Andrew's answer in Swift 3 / Swift 4:

    class MyCell: UITableViewCell {
    
        override func layoutSubviews() {
            super.layoutSubviews()
    
            for subview in self.subviews {
    
                for sub in subview.subviews {
    
                    if String(describing: sub).range(of: "UITableViewCellActionButton") != nil {
    
                        for view in sub.subviews {
    
                            if String(describing: view).range(of: "UIButtonLabel") != nil {
    
                                if let label = view as? UILabel {
    
                                    label.textColor = UIColor.black
    
                                }
    
                            }
    
                        }
    
                    }
    
                }
    
            }
    
        }
    
    }
    

提交回复
热议问题