cdts/xdts-ios 3/TreeHole/Code/Features/Chat/UIPatch/TUISystemMessageCellData+TUIPatch.m

38 lines
1.6 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// TUISystemMessageCellData+TUIPatch.m
// TreeHole
//
// Created by mambaxie on 2022/7/17.
//
#import "TUISystemMessageCellData+TUIPatch.h"
#import <JRSwizzle.h>
#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