39 lines
1.3 KiB
Objective-C
39 lines
1.3 KiB
Objective-C
//
|
|
// TUIMessageCell+TUIPatch.m
|
|
// Youth
|
|
//
|
|
// Created by mambaxie on 2022/2/16.
|
|
//
|
|
|
|
#import "TUIMessageCell+TUIPatch.h"
|
|
#import <JRSwizzle.h>
|
|
#import "NSObject+BKAssociatedObjects.h"
|
|
#import "TUIVoiceMessageCell.h"
|
|
|
|
@implementation TUIMessageCell (TUIPatch)
|
|
|
|
+ (void)load {
|
|
NSError *error;
|
|
[self jr_swizzleMethod:@selector(patch_initWithStyle:reuseIdentifier:) withMethod:@selector(initWithStyle:reuseIdentifier:) error:&error];
|
|
if (error) {
|
|
NSLog(@"patch TUI error: %@", error);
|
|
}
|
|
}
|
|
|
|
- (instancetype)patch_initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
TUIMessageCell *cell = [self patch_initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
cell.backgroundColor = cell.contentView.backgroundColor = [UIColor clearColor];
|
|
cell.readReceiptLabel.alpha = 0.0; // 移除已读
|
|
cell.avatarView.contentMode = UIViewContentModeScaleAspectFill;
|
|
cell.indicator.color = [UIColor whiteColor];
|
|
if ([cell isKindOfClass:[TUIVoiceMessageCell class]]) {
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
BOOL inComming = self.messageData.direction == MsgDirectionIncoming;
|
|
[(TUIVoiceMessageCell *)cell duration].textColor = inComming ? [UIColor whiteColor] : COLOR_WITH_RGB(0x040000);
|
|
});
|
|
}
|
|
return cell;
|
|
}
|
|
|
|
@end
|