Files
peko-ios/YuMi/Modules/YMRoom/View/TaskTip/XPTaskCompleteTipView.m
2024-04-11 17:05:27 +08:00

108 lines
2.7 KiB
Objective-C

//
// YMTaskCompleteTipView.m
// YUMI
//
// Created by YUMI on 2022/8/2.
//
#import "XPTaskCompleteTipView.h"
///tool
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
#import "UIImage+Utils.h"
///Third
#import <Masonry/Masonry.h>
@interface XPTaskCompleteTipView()
///背景
@property (nonatomic, strong) UIImageView *mainView;
///昵称
@property (nonatomic, strong) UILabel *nickLabel;
///昵称
@property (nonatomic, strong) UILabel *gotoLabel;
@end
@implementation XPTaskCompleteTipView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initSubViews];
[self initContraints];
}
return self;
}
- (void)initSubViews {
[self addSubview:self.mainView];
[self addSubview:self.nickLabel];
[self addSubview:self.gotoLabel];
}
- (void)initContraints {
[self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.mas_equalTo(self);
make.height.mas_equalTo(20);
make.width.mas_equalTo(150);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.leading.mas_equalTo(self.mainView).mas_offset(15);
}];
[self.gotoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.nickLabel.mas_trailing).mas_offset(4);
make.centerY.mas_equalTo(self.mainView);
}];
}
- (void)setDesc:(NSString *)desc {
_desc = desc;
if (desc.length) {
self.nickLabel.text = desc;
}
}
- (void)setUrl:(NSString *)url {
_url = url;
}
#pragma mark - getter
- (UIImageView *)mainView {
if (!_mainView) {
_mainView = [[UIImageView alloc] init];
_mainView.layer.cornerRadius = 10;
_mainView.layer.masksToBounds = YES;
_mainView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x5FCCE4), UIColorFromRGB(0xE15AFF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(150, 20)];
}
return _mainView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:12];
label.textColor = UIColorRGBAlpha(0x000000, 0.5);
[label sizeToFit];
label.text = YMLocalizedString(@"XPTaskCompleteTipView0");
_nickLabel = label;
}
return _nickLabel;
}
- (UILabel *)gotoLabel {
if (!_gotoLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:12];
label.textColor = [UIColor whiteColor];
[label sizeToFit];
label.text = YMLocalizedString(@"XPTaskCompleteTipView1");
_gotoLabel = label;
}
return _gotoLabel;
}
@end