NSAttributedString(FWApplication)

@interface NSAttributedString (FWApplication)

注意iOS在后台运行时,如果调用NSAttributedString解析html会导致崩溃(如动态切换深色模式时在后台解析html)。解决方法是提前在前台解析好或者后台异步到下一个主线程RunLoop

Html

  • html字符串转换为NSAttributedString对象,可设置默认系统字体和颜色(附加CSS方式)

    Declaration

    Objective-C

    + (nullable instancetype)
        fw_attributedStringWithHtmlString:(nonnull NSString *)htmlString
                        defaultAttributes:
                            (nullable NSDictionary<NSAttributedStringKey, id> *)
                                attributes;
  • html字符串转换为NSAttributedString主题对象,可设置默认系统字体和动态颜色,详见FWThemeObject

    Declaration

    Objective-C

    + (nonnull FWThemeObject<NSAttributedString *> *)
        fw_themeObjectWithHtmlString:(nonnull NSString *)htmlString
                   defaultAttributes:
                       (nullable NSDictionary<NSAttributedStringKey, id> *)
                           attributes;
  • Undocumented

    Declaration

    Objective-C

    + (NSString *)fw_CSSStringWithColor:(UIColor *)color NS_REFINED_FOR_SWIFT;
  • Undocumented

    Declaration

    Objective-C

    + (NSString *)fw_CSSStringWithFont:(UIFont *)font NS_REFINED_FOR_SWIFT;

Option