富文本配置参数
2021-09-13 本文已影响0人
不会拉磨的驴
`//配置参数
CGFloat fontSize = (CGFloat)[Flo_CommonManger fontSize];
NSString *fontName = [Flo_CommonManger Manager_getFontName];
CTFontRef fontRef = CTFontCreateWithName((CFStringRef)fontName, fontSize, NULL);
CGFloat lineSpace = [Flo_ReaderDataSource shareInstance].lineSpace;
CTTextAlignment aligment = kCTTextAlignmentJustified;
const CFIndex kNumberOfSettings = 5;
CTParagraphStyleSetting theSettings[kNumberOfSettings] = {
{kCTParagraphStyleSpecifierLineSpacingAdjustment,sizeof(CGFloat),&lineSpace},
{kCTParagraphStyleSpecifierMaximumLineSpacing,sizeof(CGFloat),&lineSpace},
{kCTParagraphStyleSpecifierMinimumLineSpacing,sizeof(CGFloat),&lineSpace},
{kCTParagraphStyleSpecifierParagraphSpacing,sizeof(CGFloat),&lineSpace},
{kCTParagraphStyleSpecifierAlignment,sizeof(aligment),&aligment}
};
CTParagraphStyleRef paragraphRef = CTParagraphStyleCreate(theSettings, kNumberOfSettings);
NSInteger theme = [Flo_CommonManger Manager_getThemeColor];
UIColor *textColor = [Flo_CommonTool gainCurrentThemeColorWithTheme:theme withAlpha:1.0];
NSMutableDictionary *ctdic = [NSMutableDictionary dictionary];
ctdic[(id)kCTForegroundColorAttributeName] = (id)textColor.CGColor;
ctdic[(id)kCTFontAttributeName] = (__bridge id)fontRef;
ctdic[(id)kCTParagraphStyleAttributeName] = (__bridge id)paragraphRef;
`