ios - Inset text in UILabel from left -
ios - Inset text in UILabel from left -
i have uilabel using display multiple lines of text. @ moment when text displayed, right against left hand side of label doesn't great. text inset left.
this code far:
if notes.objectatindex(indexpath.row) nsstring == "" { cell.noteslabel.text = "no notes display." cell.noteslabel.textalignment = nstextalignment.center } else { cell.noteslabel.textalignment = nstextalignment.left }
i looking @ objective-c examples couldn't them work , don't think looking for.
also, trying same thing different label , in case assumed have added " " end of string (as single line label) move in right, surprised see doesn't work?
thanks.
to inset text left edge, should create uilabel subclass, , override drawtextinrect:,
class rdlabel: uilabel { override func drawtextinrect(rect: cgrect) { allow newrect = cgrectoffset(rect, 10, 0) // move text 10 points right super.drawtextinrect(newrect) } }
ios swift uilabel
Comments
Post a Comment