NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

SOLVED: Day 90. Milestone Challenge (Meme Generator) - font scaling problem

Forums > 100 Days of Swift

Hello guys,

I did the milestone challenge from Day 90, but I noticed that there is a scaling problem with the font, as its physical size stays the same for all devices. In result, I get HUGE letters on iPhone SE 2020, which take 1/3 of the whole screen, and normal-sized font on a device like iPad 10.2", which in that case takes only 1/10 of the screen - the way I wanted it to be for all the devices.

Is there any way I can draw the attributed string so that it always takes a fixed part of the screen, no matter what the device is?

   

Hello,

yes there is but a quite complicated. Basically you need to start with particular font size, then measure the text with this font size and if it is too big, drop the font size, re-measure and check once again.

Paul did something like this in one of the Swift on Sundays livestreams - https://www.youtube.com/watch?v=X2RZlmjLYhk

   

Hi Filip,

Thanks again for help :)

   

Hacking with Swift is sponsored by NSSpain

SPONSORED Announcing NSSpain 2020: Remote Edition! An online, continuous conference for iOS developers. We’ll start on Thursday and finish on Friday, with talks, activities, and lots of fun for 36 hours, non-stop. Sound good? Join us!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.