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.
単語の境界で折り返す
byCharWrapping
Wrapping occurs before the first character that doesn’t fit.
文字で折り返す
byClipping
Lines are simply not drawn past the edge of the text container.
折り返さず、端を超えた文字は表示されない
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.
文字列末尾が表示され、行の先頭に三点リーダ
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.
文字列先頭が表示され、行の末尾に三点リーダ
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.
文字列先頭と末尾が表示され、中央に三点リーダ