UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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?

3      

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

3      

Hi Filip,

Thanks again for help :)

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.