I have programatically created a label which I have set the adjustsToFitWidth to true. Now I want to change its font, but I can't do that without making the font size of the label constant. Does anybody know how I could change only the font and not the font size of a UILabel in swift?
Hold the command key and click the text to bring up a pop-over menu. Choose Show SwiftUI Inspector and then you can edit the text/font properties.
Why not get the font size, and specify a new font with this value ?
let fontSize = self.label.font.pointSize;
self.label.font = UIFont(name: "HelveticaNeue", size: fontSize)
You can do it like this:
label.font = UIFont(name: "Arial", size: label.font.pointSize)
This will use the same font size, "Arial" can be whatever family you want to choose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With