LoginSignup
38
29

More than 3 years have passed since last update.

Swift5でUILabelのフォントやフォントサイズを変更する方法

Last updated at Posted at 2018-04-10

フォントを変更する場合

カスタムフォントを使用する場合。

label.font = UIFont(name:"fontname", size: 20.0)

システムフォントを使用する場合。

label.font = UIFont.systemFont(ofSize: 20.0) 
label.font = UIFont.boldSystemFont(ofSize: 20.0)
label.font = UIFont.italicSystemFont(ofSize: 20.0)

フォントサイズを変更したくないときはlabel.font.pointSizeでフォントサイズを取得できます。

フォントサイズのみ変更する場合

label.font = label.font.withSize(20)
38
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38
29