// // TUISystemMessageCellData+TUIPatch.m // TreeHole // // Created by mambaxie on 2022/7/17. // #import "TUISystemMessageCellData+TUIPatch.h" #import #import "NSObject+BKAssociatedObjects.h" @implementation TUISystemMessageCellData (TUIPatch) + (void)load { NSError *error; [self jr_swizzleMethod:@selector(patch_attributedString) withMethod:@selector(attributedString) error:&error]; if (error) { NSLog(@"patch TUI error: %@", error); } } - (NSMutableAttributedString *)patch_attributedString { NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:self.content]; NSDictionary *attributeDict = @{NSForegroundColorAttributeName:self.contentColor, NSFontAttributeName: self.contentFont}; [attributeString setAttributes:attributeDict range:NSMakeRange(0, attributeString.length)]; if (self.supportReEdit) { NSString *reEditStr = TUIKitLocalizableString(TUIKitMessageTipsReEditMessage); [attributeString appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", reEditStr]]]; // @"重新编辑" NSDictionary *attributeDict = @{NSForegroundColorAttributeName:[UIColor d_systemBlueColor]}; [attributeString setAttributes:attributeDict range:NSMakeRange(self.content.length + 1, reEditStr.length)]; [attributeString addAttribute:NSUnderlineStyleAttributeName value: [NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(self.content.length + 1, reEditStr.length)]; } return attributeString; } @end