Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6311447

Browse files
author
mengyaoyao
committed
2 parents b286663 + 1f0f335 commit 6311447

File tree

1 file changed

+20
-36
lines changed

1 file changed

+20
-36
lines changed

‎MYCoreText_Example/MYCoreTextLabel/MYCoreTextLabel.m

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -380,48 +380,32 @@ - (void)keyWord:(NSMutableAttributedString *)attributeStr
380380
#pragma mark - 判断属性
381381
- (void)judge
382382
{
383-
//文本内容
384-
if (!_textFont) {
385-
_textFont = [UIFont systemFontOfSize:14.f];
386-
}
387-
if (!_textColor) {
388-
_textColor = [UIColor blackColor];
389-
}
390-
if (!_imageSize.width||!_imageSize.height) {
391-
_imageSize = CGSizeMake(_textFont.lineHeight, _textFont.lineHeight);
392-
}
393-
if (!_linkBackAlpha) {
394-
_linkBackAlpha = 0.5f;
383+
384+
if (!_text.length) {
385+
_text = @" ";
386+
return;
395387
}
388+
389+
//文本内容
390+
if (!_textFont) _textFont = [UIFont systemFontOfSize:14.f];
391+
if (!_textColor) _textColor = [UIColor blackColor];
392+
if (!_imageSize.width||
393+
!_imageSize.height) _imageSize = CGSizeMake(_textFont.lineHeight, _textFont.lineHeight);
394+
if (!_linkBackAlpha) _linkBackAlpha = 0.5f;
396395

397396
//常规链接
398-
if (!_norLinkFont) {
399-
_norLinkFont = _textFont;
400-
}
401-
if (!_norLinkColor) {
402-
_norLinkColor = [UIColor blueColor];
403-
}
404-
if (!_norLinkBackColor) {
405-
_norLinkBackColor = [UIColor blueColor];
406-
}
397+
if (!_norLinkFont) _norLinkFont = _textFont;
398+
if (!_norLinkColor) _norLinkColor = [UIColor blueColor];
399+
if (!_norLinkBackColor) _norLinkBackColor = [UIColor blueColor];
407400

408401
//自定义链接
409-
if (!_customLinkFont) {
410-
_customLinkFont = _textFont;
411-
}
412-
if (!_customLinkColor) {
413-
_customLinkColor = [UIColor blueColor];
414-
}
415-
if (!_customLinkBackColor) {
416-
_customLinkBackColor = [UIColor blueColor];
417-
}
402+
if (!_customLinkFont) _customLinkFont = _textFont;
403+
if (!_customLinkColor) _customLinkColor = [UIColor blueColor];
404+
if (!_customLinkBackColor) _customLinkBackColor = [UIColor blueColor];
405+
418406
//关键字
419-
if (!_keyWordColor) {
420-
_keyWordColor = [UIColor blackColor];
421-
}
422-
if (!_keyWordBackColor) {
423-
_keyWordBackColor = [UIColor yellowColor];
424-
}
407+
if (!_keyWordColor) _keyWordColor = [UIColor blackColor];
408+
if (!_keyWordBackColor) _keyWordBackColor = [UIColor yellowColor];
425409
}
426410

427411
#pragma mark - 计算尺寸

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /