美文网首页iOS开发iOS DeveloperiOS高质量博客
关于TTTAttributedLabel不在xib使用的解决方法

关于TTTAttributedLabel不在xib使用的解决方法

作者: CowboyBebop | 来源:发表于2017-01-17 10:06 被阅读145次
一,之前在使用TTTAttributedLabel,发现它不能在xib使用,直接使用的话就会报下面的错误。
FB46E463-60BB-46ED-A5E6-671E786171ED.png

关于这个问题的解决方法stackoverflow上有:
http://stackoverflow.com/questions/28204108/ib-designables-failed-to-update-auto-layout-status-failed-to-load-designables

  • 1,第一种是用cocoapods导入的时候在podfile 中加上 use_frameworks!,
    然后 pod update一下 在打开项目 clean一下 就OK了.

  • 2, 第二种是写个子类继承自 TTTAttributedLabel,然后在.h文件中加上这些代码

#ifndef IB_DESIGNABLE
#define IB_DESIGNABLE
#endif

@class TTTAttributedLabel;

IB_DESIGNABLE @interface YourLabel : TTTAttributedLabel {
 ...
}

这两种方法都能解决问题。

相关文章

网友评论

本文标题:关于TTTAttributedLabel不在xib使用的解决方法

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