Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Justify-aligning text in a text view in swift

It's a pretty trivial question I know, but I have to be able to justify-align the text in a text view using swift. It is an already existing text view on the storyboard which has been hooked up to an outlet, let's call it justifyTextView.

Can anybody give some code for this? I can't seem to find anything online about it.

like image 421
Matt Spoon Avatar asked Apr 23 '15 16:04

Matt Spoon


People also ask

How do I set text alignment in SwiftUI?

To align a text view along the horizontal axis, you need to use . frame() modifier with maxWidth set to . infinity and alignment to the alignment you want.

How do I center text in SwiftUI?

When SwiftUI's Text views wrap across multiple lines, they align to their leading edge by default. If you want to change that, use the multilineTextAlignment() modifier to specify an alternative, such as . center , or . trailing .

What is center justified text?

justified—text is aligned along the left margin, with letter-spacing and word-spacing adjusted so that the text falls flush with both margins, also known as fully justified or full justification; centered—text is aligned to neither the left nor right margin; there is an even gap on each side of each line.


1 Answers

label.textAlignment = NSTextAlignment.Justified
like image 80
Shuo Avatar answered Oct 12 '22 01:10

Shuo