1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ヒラギノ角ゴを簡潔に使うExtension【Swift 5】

Posted at

こんにちは、@Zhalen です。読み方は、「ツァーレン」です。

この記事では日本人が最もよく使っているフォント、ヒラギノ角ゴ

通称HiraginoSansをよく使う方のためのExtensionを簡潔にご紹介します。

Extension


extension UIFont {
    
    enum borderStyle: String {
        case light = "HiraginoSans-W3"
        case bold = "HiraginoSans-W6"
        case extraBold = "HiraginoSans-W7"
    }
    
    static func hiraginoSans(style: borderStyle, size: CGFloat) -> UIFont {
        return UIFont(name: style.rawValue, size: size)!
    }
    
}

Usage

このようにお使いください。ちなみに、Qiitaのこの文章で使われているフォントはおそらくHiraginoSans-W3です。以前ブログをやっていたこともあり、フォントをよく選ぶようになってくると見ただけで「あ、これは〇〇のΔΔだな」というのが本当にわかってきます。


//細め
label0.font = UIFont.hiraginoSans(style: .light, size: 15)

//太め
label1.font = UIFont.hiraginoSans(style: .bold, size: 15)

//極太
label2.font = UIFont.hiraginoSans(style: .extraBold, size: 15)

<>

まとめ

好きなフォントはHelvetica Neue Ultra-light一択です。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?