|
|
@@ -254,7 +254,14 @@ + (instancetype)mj_label
|
|
|
- (CGFloat)mj_textWidth {
|
|
|
CGFloat stringWidth = 0;
|
|
|
CGSize size = CGSizeMake(MAXFLOAT, MAXFLOAT);
|
|
|
- if (self.text.length > 0) {
|
|
|
+
|
|
|
+ if (self.attributedText) {
|
|
|
+ if (self.attributedText.length == 0) { return 0; }
|
|
|
+ stringWidth = [self.attributedText boundingRectWithSize:size
|
|
|
+ options:NSStringDrawingUsesLineFragmentOrigin
|
|
|
+ context:nil].size.width;
|
|
|
+ } else {
|
|
|
+ if (self.text.length == 0) { return 0; }
|
|
|
stringWidth = [self.text boundingRectWithSize:size
|
|
|
options:NSStringDrawingUsesLineFragmentOrigin
|
|
|
attributes:@{NSFontAttributeName:self.font}
|