iOS Question set label alignment to justify

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,

try this:

B4X:
Sub Justify (L As Label, FirstLineHeadIndent As Float)
    L.Multiline = True
   
    Dim ParaStyle As NativeObject
    ParaStyle = ParaStyle.Initialize("NSMutableParagraphStyle").RunMethod("alloc",Null).RunMethod("init",Null)
    ParaStyle.SetField("alignment",3)
    ParaStyle.SetField("firstLineHeadIndent",FirstLineHeadIndent)
   
    Dim Attr As Map = CreateMap("NSParagraphStyle":ParaStyle,"NSColor":ParaStyle.ColorToUIColor(L.TextColor),"NSFont":L.Font)
   
    Dim NaAttr As NativeObject
    NaAttr = NaAttr.Initialize("NSAttributedString").RunMethod("alloc",Null).RunMethod("initWithString:attributes:",Array(L.Text,Attr.ToDictionary))
   
   
    Dim Lbl As NativeObject = L
    Lbl.SetField("attributedText",NaAttr)
End Sub

Jan
 
Upvote 0
Top