| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //
- // MOFastGiveView.m
- // MiMoLive
- //
- // Created by MiMo on 2025/7/27.
- //
- #import "MOFastGiveView.h"
- #import "MORingCountdownView.h"
- #import "UIImageView+Gift.h"
- @interface MOFastGiveView ()
- @property (nonatomic, strong) UIImageView *bgImgView;
- @property (nonatomic, strong) UIImageView *giftImgView;//礼物图片
- @property (nonatomic, strong) MORingCountdownView *countdownView;
- @property (nonatomic, assign) NSInteger addTime;//需要增加的时间
- @end
- @implementation MOFastGiveView
- - (instancetype)init {
- if (self = [super init]) {
- [self setupUI];
- }
- return self;
- }
- - (void)sendGiftAction {
- if (self.sendGiveBlock) {
- self.sendGiveBlock(self.fastGiveModel);
- }
- }
- - (void)setupUI {
- [self addSubview:self.bgImgView];
- [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_equalTo(CGSizeMake(36, 36));
- make.center.mas_equalTo(0);
- }];
-
- [self addSubview:self.giftImgView];
- [self.giftImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(0);
- }];
-
- MORingCountdownView *countdownView = [[MORingCountdownView alloc] initWithFrame:CGRectMake(0, 0, 36, 36)];
- WEAKSELF
- countdownView.stopBlock = ^{
- if (weakSelf.timeoutBlock) {
- weakSelf.timeoutBlock();
- }
- };
- [self.bgImgView addSubview:countdownView];
- self.countdownView = countdownView;
- self.countdownView.lineWidth = 2.0;
- self.countdownView.ringColor = [MOTools colorWithHexString:@"#FFF0C7"];
- [self.countdownView reloadAppearance];
- }
- - (void)startCountdonwWithTime:(NSInteger)time {
- [self.countdownView startCountdownWithDuration:time];
- }
- //动画时间再加上多长时间
- - (void)addCountdonwWithTime:(NSInteger)time {
- self.addTime += time;
- NSTimeInterval result = [self.countdownView elapsedAnimationTime];
-
- if (self.addTime >= 180) {
- self.addTime = 180;
- }
- [self.countdownView startCountdownWithDuration:self.addTime];
- }
- - (void)setFastGiveModel:(MORtmFastGive *)fastGiveModel {
- _fastGiveModel = fastGiveModel;
-
- [self.giftImgView mo_setGiftImageWith:fastGiveModel.giftImage];
- }
- - (UIImageView *)bgImgView {
- if (!_bgImgView) {
- _bgImgView = [[UIImageView alloc] init];
- _bgImgView.image = [UIImage imageNamed:@"icon_fast_give_bg"];
- }
- return _bgImgView;
- }
- - (UIImageView *)giftImgView {
- if (!_giftImgView) {
- _giftImgView = [[UIImageView alloc] init];
- _giftImgView.contentMode = UIViewContentModeScaleAspectFill;
- _giftImgView.userInteractionEnabled = YES;
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sendGiftAction)];
- [_giftImgView addGestureRecognizer:tap];
-
- }
- return _giftImgView;
- }
- @end
|