Files
yinmeng-ios/xplan-ios/Main/Message/View/Session/Content/MessageContentUnSupportView.m
2022-04-22 15:31:03 +08:00

70 lines
1.9 KiB
Objective-C

//
// MessageContentUnSupport.m
// xplan-ios
//
// Created by 冯硕 on 2022/4/19.
//
#import "MessageContentUnSupportView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#define MESSAGE_TEXT_PADDING 10
@interface MessageContentUnSupportView ()
///不支持的类型
@property (nonatomic,strong) UILabel *unSupportLabel;
@end
@implementation MessageContentUnSupportView
+ (CGFloat)measureHeight:(NIMMessage *)message {
NSString * messageText = @"暂不支持此种类型消息";
CGSize dstRect = CGSizeMake(CONTENT_WIDTH_MAX - MESSAGE_TEXT_PADDING * 2, MAXFLOAT);
CGFloat msgHeight = [messageText boundingRectWithSize:dstRect options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.height;
return msgHeight + MESSAGE_TEXT_PADDING * 2 + CONTENT_PADDING_V_TOTAL;
}
- (void)render:(NIMMessage *)message {
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.unSupportLabel];
}
- (void)initSubViewConstraints {
[self.unSupportLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self).with.insets(UIEdgeInsetsMake(MESSAGE_TEXT_PADDING, MESSAGE_TEXT_PADDING, MESSAGE_TEXT_PADDING, MESSAGE_TEXT_PADDING));
}];
}
#pragma mark - Getters And Setters
- (UILabel *)unSupportLabel {
if (!_unSupportLabel) {
_unSupportLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_unSupportLabel.preferredMaxLayoutWidth = CONTENT_WIDTH_MAX - MESSAGE_TEXT_PADDING * 2;
_unSupportLabel.textColor = ThemeColor.mainTextColor;
_unSupportLabel.text = @"暂不支持此种类型消息";
_unSupportLabel.textAlignment = NSTextAlignmentCenter;
_unSupportLabel.font = [UIFont systemFontOfSize:13];
}
return _unSupportLabel;
}
@end