NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

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 Fernando Olivares

SPONSORED Would you describe yourself as knowledgeable, but struggling when you have to come up with your own code? Fernando Olivares has a new book containing iOS rules you can immediately apply to your coding habits to see dramatic improvements, while also teaching applied programming fundamentals seen in refactored code from published apps.

Try the book!

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.