Shen
Shen

Reputation: 644

Changing font size in a label for only iPhone 4s, is this possible?

I'm working in Portrait mode. I'm looking for a way to change the font size of text in a label so it only applies to the iPhone 4s. I understand that regular height/compact width applies to the iPhone 4s, 5, and 6. But with my app the way it is, I have to make my font size so small just to make it 4s compatible. On the 5 it looks alright, but it makes viewing it on the 6 very very ugly (being of how miniscule it looks). What would you guys do in this situation?

Is there any way to do this programmatically even? If this isn't possible, how could Apple miss this? Doesn't it make more sense to put the 4s in it's own subcategory with regards to it's height?

I am programming in Swift.

Upvotes: 0

Views: 792

Answers (1)

Leo Dabus
Leo Dabus

Reputation: 236370

Detecting the device model:

if UIDevice.currentDevice().model == "iPhone4,1" {
    // do whatever you want here for iPhone 4S
} else {
   // other devices 
}

nativeBounds

The bounding rectangle of the physical screen, measured in pixels. (read-only)

Declaration SWIFT

  var nativeBounds: CGRect { get }

This rectangle is based on the device in a portrait-up orientation. This value does not change as the device rotates.

Import Statement

import UIKit

Detecting the device's height:

if UIScreen.mainScreen().nativeBounds.height == 960.0 {

}

Detecting the device's width:

if UIScreen.mainScreen().nativeBounds.width == 640.0 {

}

Upvotes: 3

Related Questions