Files
yinmeng-ios/xplan-ios/Main/Room/View/TaskTip/XPTaskCompleteTipView.m
2022-08-02 18:13:51 +08:00

109 lines
2.6 KiB
Objective-C

//
// XPTaskCompleteTipView.m
// xplan-ios
//
// Created by GreenLand on 2022/8/2.
//
#import "XPTaskCompleteTipView.h"
///tool
#import "ThemeColor.h"
#import "XPMacro.h"
///Third
#import <Masonry/Masonry.h>
@interface XPTaskCompleteTipView()
///背景
@property (nonatomic, strong) UIView *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.left.mas_equalTo(self.mainView).mas_offset(15);
}];
[self.gotoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickLabel.mas_right).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
- (UIView *)mainView {
if (!_mainView) {
_mainView = [[UIView alloc] init];
_mainView.layer.cornerRadius = 10;
_mainView.layer.masksToBounds = YES;
_mainView.layer.borderWidth = 0.5;
_mainView.layer.borderColor = UIColorFromRGB(0xFFBC51).CGColor;
_mainView.backgroundColor = UIColorFromRGB(0x7A4B00);
}
return _mainView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:12];
label.textColor = [UIColor whiteColor];
[label sizeToFit];
label.text = @"任务已完成";
_nickLabel = label;
}
return _nickLabel;
}
- (UILabel *)gotoLabel {
if (!_gotoLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:12];
label.textColor = UIColorFromRGB(0xFFBC51);
[label sizeToFit];
label.text = @"查看奖励";
_gotoLabel = label;
}
return _gotoLabel;
}
@end