Files
peko-ios/YuMi/Modules/YMRoom/View/AnchorCycleView/AnchorRoomSrollTipView.m
2024-04-11 15:47:44 +08:00

100 lines
2.7 KiB
Objective-C

//
// AnchorRoomSrollTipView.m
// YUMI
//
// Created by YUMI on 2022/7/14.
//
#import "AnchorRoomSrollTipView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
@interface AnchorRoomSrollTipView()
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIImageView *tipImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation AnchorRoomSrollTipView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Response
- (void)onTapSkillTip:(UITapGestureRecognizer *)ges {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"isShow" forKey:@"kHadShowAnchorRoomTipKey"];
[defaults synchronize];
[self removeFromSuperview];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.bgView];
[self addSubview:self.tipImageView];
[self addSubview:self.titleLabel];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapSkillTip:)];
[self addGestureRecognizer:tap];
}
- (void)initSubViewConstraints {
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(0);
}];
[self.tipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.centerY.mas_equalTo(self).mas_offset(-40);
make.size.mas_equalTo(CGSizeMake(87, 92));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.tipImageView.mas_bottom).mas_offset(46);
make.left.right.equalTo(self).inset(10);
}];
}
- (UIView *)bgView {
if (!_bgView) {
_bgView = [[UIView alloc] init];
_bgView.backgroundColor = UIColorRGBAlpha(0x000000, 0.6);
}
return _bgView;
}
- (UIImageView *)tipImageView {
if (!_tipImageView) {
_tipImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"anchor_scroll_tip"]];
_tipImageView.contentMode = UIViewContentModeScaleAspectFit;
_tipImageView.userInteractionEnabled = YES;
}
return _tipImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = YMLocalizedString(@"AnchorRoomSrollTipView0");
_titleLabel.adjustsFontSizeToFitWidth = YES;
_titleLabel.font = [UIFont systemFontOfSize:20];
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
@end