Custom UILabel Text Alignment

After research i have found that, there are only three Default options for label text alignment are aligned left, right and center .

Beside this if i don't want any of these alignment and want my own custom alignment of the text accord to my desire.can i achieve this? If there are any suggestions please provide.

Why i want this is i have label and align the text to left. But i need certain boundary in the label and i provided it. But when i provide the boundary to the label then the first letter of the cannot be seen properly because of the boundary width.I need to align the word from left neither right nor center.

What can i do in this case.???


Use NSAttributedString with a NSParagraphStyle to set indent values. You can indent the first line, or all lines with these parameters:

  • firstLineHeadIndent
  • headIndent
  • tailIndent
  • Alternatively

    For single line labels that need some padding, I often use a UIButton with isUserInteractionEnabled=false . Then you can easily set contentInsets without worrying about setting an NSAttributedString and you get vertical padding as well.

    链接地址: http://www.djcxy.com/p/28270.html

    上一篇: ios6 uilabel没有对齐中心文本

    下一篇: 自定义UILabel文本对齐