I'm using the newest version of Xcode
and Swift
.
I have a Navigation Bar
with a Navigation Item Title
.
On some devices with smaller screens this title is too long so it's getting truncated.
My idea is:
First I count how many characters fit on a specific width. (Of course with an allowance of 2-3 characters, because some characters are bigger than others.)
I have to possible titles, the one is longer with a width of x characters, the other is the shorter alternate with a width of y characters.
Now I check if the longer title will fit depending on its character count and the maximum count of characters the current screen can take. If not, I'll present its shorter alternate.
I want to do the measurement of the screen width with the following code:
let screenWidth = UIScreen.main.bounds.size.width
Is this the right one to do this? Or will this e.g. output different values depending on screen resolution, although the real width of the device is the same …
What unit is this? Pixels?
Note: The app is in portrait mode, so width
is also the real devices width.