Reputation: 6612
I'm currently working with the following : Swift (1.2), Xcode (6.3) and iOS 8.3.
I currently have an application that look similar to this sample I've made for this question :
For each UIButton / UILabel I would like to configure their font size depending on which device is used (iPhone 4s to iPhone 6 Plus for example).
As you can see I tried to use the "text-displaying control" in order to add a large font size (44) and another one smaller (33). For this second one, the setting is on "Width: Compact ; Height: Any".
Below are my current results :
However, as you can see, the font on the iPhone 6 Plus is still the little one. I tried to change the settings (of the little font) for "Width: Compact ; Height: Regular" and with the System font ; but the result is the same :(
How could I have something like this (iPhone 6 Plus with the large font size) ?
Is there a way to :
UIScreen.mainScreen().bounds.size.width
?Upvotes: 1
Views: 1899
Reputation: 535989
I just went through something like this with one of my own apps, and settled on this solution:
// global utility...
var on6plus : Bool {
return UIScreen.mainScreen().traitCollection.displayScale > 2.5
}
// and then, in my view controller's viewDidLoad...
if on6plus {
for lab in [self.scoreLabel, self.prevLabel, self.stageLabel] {
let f = lab.font
lab.font = f.fontWithSize(f.pointSize + 2)
}
}
Upvotes: 2