Custom Font Sizing in Xcode 6 Size Classes not working properly with Custom Fonts

前端 未结 14 1270
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 17:42

Xcode 6 has a new feature where fonts and font sizes in UILabel, UITextField, and UIButton can be s

14条回答
  •  粉色の甜心
    2020-11-29 18:38

    I had the same problem and found one not really clear, but fine solution!

    1. First you set the required font size in storyboard with system font name.
    2. Then to this label you assign a tag from 100 to 110 (or more, but 10 was always enough for me in one view controller).
    3. Then put this code to your VC's source file and don't forget to change font name. Code in swift.
    override func viewDidLayoutSubviews() {
        for i in 100...110 {
            if let label = view.viewWithTag(i) as? UILabel {
                label.font = UIFont(name: "RotondaC-Bold", size: label.font.pointSize)
            }
        }
    }
    

提交回复
热议问题