AliSoftware / OHAttributedLabel

UILabel that supports NSAttributedString
https://github.com/AliSoftware/OHAttributedLabel/wiki
1.51k stars 344 forks source link

About OHAttributedLabel padding question #114

Closed mjspawn closed 11 years ago

mjspawn commented 11 years ago

iOS 2013-1-15 11 23 33 why padding not the same?I use \n to line break and ohLabel.lineBreakMode = NSLineBreakByWordWrapping; ohLabel.attributedText = [OHASBasicHTMLParser attributedStringByProcessingMarkupInAttributedString:cell.ohLabel.attributedText];

mjspawn commented 11 years ago

i figure it out using {.spec = kCTParagraphStyleSpecifierMinimumLineSpacing,.valueSize = sizeof(CGFloat), .value = (const void)&lineSpacing}, {.spec = kCTParagraphStyleSpecifierMaximumLineSpacing,.valueSize = sizeof(CGFloat), .value = (const void)&lineSpacing}

AliSoftware commented 11 years ago

You should use the new OHParagraphStyle for that (that I added in the latest versions), it is a wrapper around CTParagraphStyle that is easier to use than the CTParagraphStyle C structures. See my demo project, I demonstrate it already.


_By the way, to be frank I didn't understand your question as:

  1. you talk about padding at first but solve it with line spacing (which is a different font attribute than padding)
  2. you didn't annotate your screen capture so I was unable to understand which part of your image you were talking about_