39
33

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の改行まとめ

Posted at

UILabelの改行の種類をいつも調べてる気がするので備忘録代わりにまとめた

let label = UILabel(frame: .zero)
label.lineBreakMode = .byWordWrapping

lineBreakModeの型であるNSLineBreakModeのドキュメントを見ると、改行方法は6種類ある

byWordWrapping

Wrapping occurs at word boundaries, unless the word itself doesn’t fit on a single line. See Characters and Grapheme Clusters in String Programming Guide for a discussion of issues related to determining word boundaries.

20170317195406.png

単語の境界で折り返す

byCharWrapping

Wrapping occurs before the first character that doesn’t fit.

20170317200325.png

文字で折り返す

byClipping

Lines are simply not drawn past the edge of the text container.

20170317200325.png

折り返さず、端を超えた文字は表示されない

byTruncatingHead

The line is displayed so that the end fits in the container and the missing text at the beginning of the line is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.

20170317200802.png

文字列末尾が表示され、行の先頭に三点リーダ

byTruncatingTail

The line is displayed so that the beginning fits in the container and the missing text at the end of the line is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.

20170317200954.png

文字列先頭が表示され、行の末尾に三点リーダ

byTruncatingMiddle

The line is displayed so that the beginning and end fit in the container and the missing text in the middle is indicated by an ellipsis glyph. This mode is used for single-line layout; using it with multiline text truncates the text into a single line.

20170317201055.png

文字列先頭と末尾が表示され、中央に三点リーダ

39
33
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
39
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?