Technology

Dynamic Text Resizing in Swift

Creating a great user experience lies in making every interaction feel nature and intended to the user.

In a recent project, to make interactions feel more catered, I needed a UILabel to have it’s text scale to fit its bounds to the best extent that it can.

Usage

The implementation can be extended for any UI element (such as UILabel):

let label = UILabel()
label.font = UIFont.preferredFont(forTextStyle: .headline)

iOS Font Sizes

StyleFontSize
.largeTitleSFUIDisplay34.0
.title1SFUIDisplay
(-Light on iOS <=10)
28.0
.title2SFUIDisplay22.0
.title3SFUIDisplay20.0
.headlineSFUIText-Semibold17.0
.calloutSFUIText16.0
.subheadlineSFUIText15.0
.bodySFUIText17.0
.footnoteSFUIText13.0
.caption1SFUIText12.0
.caption2SFUIText11.0
admin

Recent Posts

Create PHP-FPM Status Page for nginx+php-fpm in directadmin

Go to Custom HTTPD ConfigurationSelect the php-fpm version you are running for the domain you…

3 years ago

Renew Let’s Encrypt For Domains Command Line

cd /usr/local/directadmin/scripts ./letsencrypt.sh renew [domain.com] 4096

4 years ago

server reached pm.max_children setting (10), consider raising it.

We calculate based on the following formula: pm.max_children = Total RAM dedicated to the web…

4 years ago

Install VPN Server by script openvpn-install

I would like to introduce to you, the simplest and easiest way to install OpenVPN…

4 years ago

Instructions to upgrade DirectAdmin version

cd /usr/local/directadmin/custombuild/ ./build update ./build update_da

4 years ago

Directadmin change httpd to nginx

cd /usr/local/directadmin/custombuild ./build set webserver nginx ./build update ./build set php1_mode php-fpm ./build set php2_mode…

4 years ago