Files
peko-ios/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallHeadView.m
2024-06-07 17:10:06 +08:00

56 lines
1.8 KiB
Objective-C

//
// MsRoomMessagChatHallHeadView.m
// YuMi
//
// Created by duoban on 2024/6/3.
//
#import "MsRoomMessagChatHallHeadView.h"
@interface MsRoomMessagChatHallHeadView()
@property(nonatomic,strong) UILabel *titleView;
@end
@implementation MsRoomMessagChatHallHeadView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
self.layer.cornerRadius = 7;
self.layer.masksToBounds = YES;
self.layer.borderWidth = 1;
[self addSubview:self.titleView];
}
-(void)installConstraints{
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.bottom.equalTo(self).inset(10);
}];
}
-(void)setContent:(NSString *)content{
_content = content;
_titleView.text = _content;
}
-(void)setUIColor{
[_titleView.superview layoutIfNeeded];
UIImage *bgImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xE3B462),UIColorFromRGB(0x723505)] gradientType:GradientTypeLeftToRight imgSize:self.frame.size];
self.backgroundColor = [UIColor colorWithPatternImage:bgImage];
UIImage *borderImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xF7D364),UIColorFromRGB(0xFFFAE4),UIColorFromRGB(0xF7D364)] gradientType:GradientTypeLeftToRight imgSize:self.frame.size];
self.layer.borderColor = [UIColor colorWithPatternImage:borderImage].CGColor;
}
#pragma mark - 懒加载
- (UILabel *)titleView{
if(!_titleView){
_titleView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:13 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0xFFF6E1)];
_titleView.textAlignment = NSTextAlignmentCenter;
_titleView.numberOfLines = 0;
}
return _titleView;
}
@end