Skip to content

Commit

Permalink
_addCommonValuesToRecorderIfNeed
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Sep 11, 2018
1 parent ed41d23 commit 867a52a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
Binary file not shown.
25 changes: 25 additions & 0 deletions Demo/SJAttributesFactory/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,31 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
make.regexp(@"^[\\p{S}|\\p{P}|\\p{M}|\\p{Z}]+$", ^(SJAttributesRangeOperator * _Nonnull make) {
make.textColor([UIColor redColor]);
});

[self updateConstraintsWithSize:make.sizeByWidth(self.view.bounds.size.width - 80)];
});
}
break;

case 9: {

tips = @"测试";

attr = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {

make.font([UIFont boldSystemFontOfSize:30]);

make.append(@"lalalalalalalsho sj");

make.regexp(@"sj", ^(SJAttributesRangeOperator * _Nonnull make) {
make.textColor([UIColor blueColor]);
});

make.regexp(@"^((?!shop[\\s]*).)*sj", ^(SJAttributesRangeOperator * _Nonnull make) {
make.textColor([UIColor redColor]);
});

[self updateConstraintsWithSize:make.sizeByWidth(self.view.bounds.size.width - 80)];
});
}
break;
Expand Down
2 changes: 1 addition & 1 deletion SJAttributesFactory.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "SJAttributesFactory"
s.version = "2.0.3.3"
s.version = "2.0.3.4"
s.summary = "富文本编辑工厂."

# This description is used to generate tags and improve search results.
Expand Down
7 changes: 7 additions & 0 deletions SJAttributesFactory/SJAttributeWorker.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,18 @@ - (NSMutableAttributedString *)endTask {
if ( nil == self.recorder.textColor ) self.recorder.textColor = self.defaultTextColor;
_addAttributes(self, self.attrStr);
[self.rangeOperatorsM enumerateObjectsUsingBlock:^(SJAttributesRangeOperator * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[self _addCommonValuesToRecorderIfNeed:obj.recorder];
_addAttributes(obj, self.attrStr);
}];
return self.attrStr;
}

- (void)_addCommonValuesToRecorderIfNeed:(SJAttributesRecorder *)recorder {
if ( nil == recorder.font ) recorder.font = self.recorder.font;
if ( 0 == recorder.lineSpacing ) recorder.lineSpacing = self.recorder.lineSpacing;
//if ( nil == recorder.textColor ) recorder.textColor = self.recorder.textColor;
}

BOOL _addAttributes(SJAttributesRangeOperator *operator, NSMutableAttributedString *attrStr) {
if ( operator.recorder_value_added ) return NO;
[operator.recorder addAttributes:attrStr];
Expand Down

0 comments on commit 867a52a

Please sign in to comment.