lineLimit(_:)
Sets to a closed range the number of lines that text can occupy in this view.
Declaration
nonisolated func lineLimit(_ limit: ClosedRange<Int>) -> some View
Parameters
- limit:
The line limit.
Discussion
Use this modifier to specify a closed range of lines that a Text view or a vertical TextField can occupy. When the text of such views occupies more space than the provided limit, a Text view truncates its content while a TextField becomes scrollable.
Form {
TextField("Title", text: $model.title)
TextField("Notes", text: $model.notes, axis: .vertical)
.lineLimit(1...3)
}