2016-08-03 3 views
0

私のコードでカスタムフォントを使用しています。それを使用した後、文字はUIの問題を引き起こしている1行に整列されません。 enter image description hereiOSのカスタムフォントの配置を管理する

私はそれは以下のように見えるようにフォントやラベルの設定を変更したい: enter image description here

任意のヘルプ?

答えて

0

私はそれがFontスタイルのためだと思うので、テキストをNSAttributedString文字列として設定し、それに従ってFontを管理することができます。その場合、異なるAttributesを持つ2つのNSMutableAttributedStringを作成し、それを使用します。

extension String { 

    func getText() -> NSAttributedString { 
     let str1 = "Hello" 
     let str2 = "750" 

     //create attribute 
     let attStr1  = NSMutableAttributedString(string: str1) 
     let attFormat = [NSFontAttributeName : UIFont.systemFontOfSize(10.0)] 
     let attString = NSMutableAttributedString(string: str2, attributes: attFormat) 
     attString.appendAttributedString(attStr1) 

     return attString 
    } 
} 

はちょうどあなたの要件に応じて Attribute作成し、それが動作します。

関連する問題