label 字间距 行间距设置

时间:2022-05-16 06:10:07
label 字间距 行间距设置

群里讨论看到 ,先记下来,会用到的。

在drowInrect里

//设置字间距

if(self.characterSpacing)

{

 long number = self.characterSpacing;

 CFNumberRef num = CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt8Type,&number);

 [string addAttribute:(id)kCTkernAttributeName value:(id)num rang:NSMakeRange(0,[string length])];

 CFRelease(num);

}

//设置文本行间距

CGFloat lineSpace = self.linesSpacing;

CTParagraphStyleSetting lineSpaceStyle;

lineSpaceStyle.spec = kCTparagraphStyleSpecifierLineSpacingAdjustment;

lineSpaceStyle.valueSize = sizeof(lineSpace);

lineSpaceStyle.value =&lineSpace;


本文出自 “iOS悠悠Bug记” 博客,请务必保留此出处http://ios2013yoyo.blog.51cto.com/6260005/1272974