LoginSignup
1
0

More than 5 years have passed since last update.

NSAttributedStringのboundingRectのサイズにUILabelを設定したのに…になってしまう時

Posted at

NSAttributedStringのサイズをboundingRectで計算してUILabelのサイズに適用すると

Simulator Screen Shot - iPhone 6s - 2018-03-15 at 16.40.48.png

本来文字が入り切るサイズのはずなのにこうなることがある。

こういう時はNSAttributedStringにfontを明示的に指定する。
そうすると

Simulator Screen Shot - iPhone 6s - 2018-03-15 at 16.40.57.png

こんな感じになる。
おそらくUILabelとNSAttributedStringのデフォルトのフォント設定が微妙に違うんだろうなー

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