Friday, May 20, 2022
HomeiOS Developmentios - Why does UIButton Label ingnores look setting when contained in...

ios – Why does UIButton Label ingnores look setting when contained in UITableView tableHeaderView?


I’ve created a easy UIViewController which comprises a UITableView. When including a tableHeaderView which features a UIButton it appears to not be doable to alter the button label utilizing look settings. Different buttons exterior the tableHeaderView are up to date accurately.

enter image description here
enter image description here

Right here the button which was positioned immediately within the ViewControllers view is up to date accurately whereas the looks settings appear to not impact the button contained in the tableHeaderView.

class ListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet weak var tableHeaderView: UIView!
    @IBOutlet weak var tableView: UITableView!
    
    override func viewDidLoad() {
        UILabel.look(whenContainedInInstancesOf: [TestButton.self]).font = UIFont.systemFont(ofSize: 30)
        UILabel.look(whenContainedInInstancesOf: [TestButton.self]).textColor = .pink
        
        tremendous.viewDidLoad()
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
        tableView.tableHeaderView = tableHeaderView
    }
    
    ...
}

class TestButton: UIButton {}

There are actually different look settings within the mission which could clarify this. Transferring the looks settings to another place, e.g. software:didFinishLaunchingWithOptions doesn’t change the issue.

Is that this a bug or am I lacking one thing?

RELATED ARTICLES

Most Popular

Recent Comments