美文网首页
富文本配置参数

富文本配置参数

作者: 不会拉磨的驴 | 来源:发表于2021-09-13 16:17 被阅读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;
    

    `

    相关文章

      网友评论

          本文标题:富文本配置参数

          本文链接:https://www.haomeiwen.com/subject/glefgltx.html