Hello,
I have a Table View Controller with a custom Header, customized in this function:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let shopHeader = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 70))
shopHeader.backgroundColor = UIColor(red: 209/255, green: 226/255, blue: 254/255, alpha: 1)
let backShop = UIButton(frame: CGRect(x: 10, y: 20, width: 90, height: 30))
backShop.setTitle("< back", for: .normal)
backShop.setTitleColor(UIColor.black, for: .normal)
backShop.titleLabel?.font = UIFont(name: "Jack Armstrong", size: 20)
backShop.addTarget(self, action: #selector(pressed), for: .touchUpInside)
shopHeader.addSubview(backShop)
coins = UILabel(frame: CGRect(x: tableView.frame.size.width - 280, y: 20, width: 200, height: 30))
coins.text = String(UserDefaults.standard.integer(forKey: "Total"))
coins.font = UIFont(name: "Jack Armstrong", size: 17)
coins.textAlignment = NSTextAlignment.right
shopHeader.addSubview(coins)
return shopHeader
}
where coins is a global var. I have another function which job is change the text of the UILabel coins, but when I call this function the text doesn't change. What am I doing wrong? Is it mutable the Header of a TableView once it's loaded?