48
42

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 5 years have passed since last update.

UILabelでうまく改行できないときの確認ポイント

Last updated at Posted at 2014-08-07

#概要

UILabelでうまく改行できないときの確認ポイント

Storyboard

  • Linesが1以外(0で無制限)

  • Line BreaksがCharacter Wrap(場合によってはWord Wrap)

  • Use AutoLayoutにチェックを入れ、Constraintを設定する。(iOS7では必須)

  • Storyboard下方にあるPINボタン(|- + -|)を押すとConstraint設定画面に移る

Code

  • adjustsFontSizeToFitWidthプロパティをNO(フォントサイズの変更でアジャストされてしまう)

  • テキストを設定後、sizeToFitメソッドをコール

補足

Webで情報を検索するとConstraintに触れられていないことが多く、iOS6まではこの設定が不要だったのかも

参考

48
42
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
48
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?