@@ -180,7 +180,7 @@ - (void)setText:(NSString *)text linkRanges:(NSArray<NSValue *> *) ranges keywor
180
180
- (void )render
181
181
{
182
182
// 属性矫正
183
- [self judge ];
183
+ if (! [self judge ]) return ;
184
184
// 复用处理
185
185
[self reuseHandle ];
186
186
[self configAttribute: _text];
@@ -510,14 +510,12 @@ - (void)keyWord:(NSMutableAttributedString *)attributeStr
510
510
}
511
511
512
512
#pragma mark - 判断属性
513
- - (void )judge
513
+ - (BOOL )judge
514
514
{
515
515
516
516
if (!_text.length ) {
517
- _text = @" " ;
518
- return ;
517
+ return NO ;
519
518
}
520
-
521
519
// 文本内容
522
520
if (!_textFont) _textFont = [UIFont systemFontOfSize: 14 .f];
523
521
if (!_textColor) _textColor = [UIColor blackColor ];
@@ -559,13 +557,14 @@ - (void)judge
559
557
if (!_keywordFont) _keywordFont = _textFont;
560
558
if (!_keyWordColor) _keyWordColor = [UIColor blackColor ];
561
559
if (!_keyWordBackColor) _keyWordBackColor = [UIColor yellowColor ];
560
+ return YES ;
562
561
}
563
562
564
563
#pragma mark - 计算尺寸
565
564
- (CGSize)sizeThatFits : (CGSize)size
566
565
{
567
- if (!self.contentTextView .attributedText .length ) {
568
- return CGSizeZero ;
566
+ if (!self.contentTextView .attributedText .length ||!_text. length ) {
567
+ return CGSizeMake ( 0 , 0 ) ;
569
568
}
570
569
CGSize viewSize = [self .contentTextView sizeThatFits: CGSizeMake (size.width, size.height)];
571
570
return viewSize;
0 commit comments