diff --git a/Demo/SJAttributesFactory.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate b/Demo/SJAttributesFactory.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate index 6e4cf05..3ccd6bc 100755 Binary files a/Demo/SJAttributesFactory.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate and b/Demo/SJAttributesFactory.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Demo/SJAttributesFactory/ViewController.m b/Demo/SJAttributesFactory/ViewController.m index e2f98b5..93c7f60 100755 --- a/Demo/SJAttributesFactory/ViewController.m +++ b/Demo/SJAttributesFactory/ViewController.m @@ -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; diff --git a/SJAttributesFactory.podspec b/SJAttributesFactory.podspec index 0a7583b..cf4a207 100755 --- a/SJAttributesFactory.podspec +++ b/SJAttributesFactory.podspec @@ -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. diff --git a/SJAttributesFactory/SJAttributeWorker.m b/SJAttributesFactory/SJAttributeWorker.m index 3c15cc0..fad2f6f 100755 --- a/SJAttributesFactory/SJAttributeWorker.m +++ b/SJAttributesFactory/SJAttributeWorker.m @@ -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];