I have a header label which I am adjusting the font size of, to fit to the size of the label. I would like to store the value of that font size so I can set the font size of some buttons to it.
I have tried to just store the pointSize of the label, but that just gives me the unadjusted value, not the value that is actually in effect.
The reason for this is, that I want the size of all the text in labels and buttons to look good on different sized iPad screens. But I am struggling with keeping the size the same, across multiple elements.
class ViewController: UIViewController {
@IBOutlet weak var essenceButton: UIButton!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var tribesButton: UIButton!
@IBOutlet weak var creaturesButton: UIButton!
@IBOutlet weak var monstersButton: UIButton!
@IBOutlet weak var musesButton: UIButton!
@IBOutlet weak var newsletterButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
self.titleLabel.adjustsFontSizeToFitWidth = true
let fontsize = self.titleLabel.font.pointSize
self.essenceButton.titleLabel?.font = essenceButton.titleLabel?.font.withSize(fontsize)
self.tribesButton.titleLabel?.font = tribesButton.titleLabel?.font.withSize(fontsize)
}
}