Files
featherVoice/QXLive/Room(房间)/View/麦位视图/QXRoomSeatBarCabinView.m
2026-01-14 20:36:58 +08:00

595 lines
24 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// QXRoomSeatBarCabinView.m
// QXLive
//
// Created by 启星 on 2026/1/5.
//
#import "QXRoomSeatBarCabinView.h"
#import "QXMineNetwork.h"
#import "UIView+FloatingAnimation.h"
#import "QXAgoraEngine.h"
#import "QXSeductionAlertView.h"
@class QXRoomSeatBarCabinGiftView;
@interface QXRoomSeatBarCabinView()<QXRoomSeatBarCabinGiftViewDelegate>
//倒计时
@property (nonatomic,strong)UIImageView *timeDownBgView;
@property (nonatomic,strong)UILabel *timeDownLabel;
@property (nonatomic,strong)QXRoomSeatContentView *leftSeatView;
//@property (nonatomic,strong)UIImageView *bgImageView;
@property (nonatomic,strong)UIImageView *heartCenterImageView;
@property (nonatomic,strong)UILabel *numberLabel;
@property (nonatomic,strong)QXRoomSeatContentView *rightSeatView;
/// 退出房间按钮
@property (nonatomic,strong) UIButton *closeBtn;
///
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UIView *giftContentView;
@property (nonatomic,strong) QXRoomSeatBarCabinGiftView *giftView1;
@property (nonatomic,strong) QXRoomSeatBarCabinGiftView *giftView2;
@property (nonatomic,strong) QXRoomSeatBarCabinGiftView *giftView3;
@property (nonatomic,strong) QXRoomSeatBarCabinGiftView *giftView4;
@property (nonatomic,strong) QXRoomSeatBarCabinGiftView *giftView5;
@property (nonatomic,strong) QXRoomSeatBarCabinGiftView *giftView6;
@property (nonatomic,strong) NSMutableArray *dataArray;
@property (nonatomic,strong) NSMutableArray *giftViewArray;
@property (nonatomic,strong)UIButton *micBtn;
@property (nonatomic,strong)UIButton *voiceBtn;
@property (nonatomic,strong)UIButton *openCabinBtn;
@property (nonatomic,strong)QXTimer *timer;
@property (nonatomic,assign)long startTime;
@property (nonatomic,assign)BOOL isNoAlert;
@end
@implementation QXRoomSeatBarCabinView
- (instancetype)init
{
self = [super init];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(rechargeSuccess) name:noticeAlipayResult object:nil];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.text = @"房间名称";
self.titleLabel.font = [UIFont systemFontOfSize:14];
self.titleLabel.textColor = [UIColor whiteColor];
[self addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(2);
make.left.mas_equalTo(16);
make.height.mas_equalTo(ScaleWidth(30));
}];
self.closeBtn = [[UIButton alloc] init];
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.closeBtn setImage:[UIImage imageNamed:@"room_close"] forState:(UIControlStateNormal)];
[self addSubview:self.closeBtn];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(ScaleWidth(40));
make.right.mas_equalTo(-5);
make.centerY.equalTo(self.titleLabel);
}];
// self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_friend_cabin_bg"]];
// self.bgImageView.contentMode = UIViewContentModeScaleToFill;
// [self addSubview:self.bgImageView];
// [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.top.equalTo(self);
// make.height.mas_equalTo(ScaleWidth(330));
// }];
self.timeDownLabel = [[UILabel alloc] initWithFrame:self.timeDownBgView.frame];
self.timeDownLabel.textColor = [UIColor colorWithHexString:@"#ffffff"];
self.timeDownLabel.font = [UIFont systemFontOfSize:12];
self.timeDownLabel.text = @"倒计时00:00:00";
self.timeDownLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.timeDownLabel];
[self.timeDownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self.titleLabel.mas_bottom).offset(16);
make.height.mas_equalTo(24);
}];
self.timeDownBgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_cabin_timedown_bg"]];
self.timeDownBgView.contentMode = UIViewContentModeScaleToFill;
[self insertSubview:self.timeDownBgView belowSubview:self.timeDownLabel];
[self.timeDownBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.timeDownLabel);
}];
self.heartCenterImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bar_room_cabin_heart"]];
[self addSubview:self.heartCenterImageView];
[self.heartCenterImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self.timeDownBgView).offset(38);
make.height.mas_equalTo(ScaleWidth(120));
make.width.mas_equalTo(ScaleWidth(128));
}];
self.numberLabel = [[UILabel alloc] init];
self.numberLabel.text = @"0";
self.numberLabel.textAlignment = NSTextAlignmentCenter;
self.numberLabel.textColor = [UIColor colorWithHexString:@"#FF07C5"];
self.numberLabel.font = [UIFont fontWithName:@"DIN Alternate" size:24];
[self addSubview:self.numberLabel];
[self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.heartCenterImageView).offset(-5);
make.centerX.equalTo(self.heartCenterImageView);
}];
self.leftSeatView = [[QXRoomSeatContentView alloc] init];
[self addSubview:self.leftSeatView];
[self.leftSeatView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.heartCenterImageView.mas_left);
make.width.mas_equalTo(ScaleWidth(75));
make.height.mas_equalTo(ScaleWidth(75)+25);
make.top.equalTo(self.heartCenterImageView).offset(-7);
}];
self.rightSeatView = [[QXRoomSeatContentView alloc] init];
[self addSubview:self.rightSeatView];
[self.rightSeatView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.heartCenterImageView.mas_right);
make.width.mas_equalTo(ScaleWidth(75));
make.height.mas_equalTo(ScaleWidth(75)+25);
make.top.equalTo(self.leftSeatView);
}];
CGFloat giftConetntHeight = 180;
CGFloat giftWidth = 72;
CGFloat giftHeight = 85;
CGFloat giftWidthSpace = (SCREEN_WIDTH-32-giftWidth*4)/3;
CGFloat giftHeightSpace = 10;
self.giftContentView = [[UIView alloc] init];
[self addSubview:self.giftContentView];
[self.giftContentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.heartCenterImageView.mas_bottom).offset(-15);
make.left.mas_equalTo(16);
make.right.mas_equalTo(-16);
make.height.mas_equalTo(giftConetntHeight);
}];
self.giftView1 = [[QXRoomSeatBarCabinGiftView alloc] initWithFrame:CGRectMake(0, (giftConetntHeight-85)/2, giftWidth, giftHeight)];
self.giftView1.delegate = self;
[self.giftContentView addSubview:self.giftView1];
self.giftView2 = [[QXRoomSeatBarCabinGiftView alloc] initWithFrame:CGRectMake(self.giftView1.right+giftWidthSpace, 0, giftWidth, giftHeight)];
self.giftView2.delegate = self;
[self.giftContentView addSubview:self.giftView2];
self.giftView3 = [[QXRoomSeatBarCabinGiftView alloc] initWithFrame:CGRectMake(self.giftView2.right+giftWidthSpace, 0, giftWidth, giftHeight)];
self.giftView3.delegate = self;
[self.giftContentView addSubview:self.giftView3];
self.giftView4 = [[QXRoomSeatBarCabinGiftView alloc] initWithFrame:CGRectMake(self.giftView3.right+giftWidthSpace, (giftConetntHeight-85)/2, giftWidth, giftHeight)];
self.giftView4.delegate = self;
[self.giftContentView addSubview:self.giftView4];
self.giftView5 = [[QXRoomSeatBarCabinGiftView alloc] initWithFrame:CGRectMake(self.giftView1.right+giftWidthSpace, self.giftView2.bottom+giftHeightSpace, giftWidth, giftHeight)];
self.giftView5.delegate = self;
[self.giftContentView addSubview:self.giftView5];
self.giftView6 = [[QXRoomSeatBarCabinGiftView alloc] initWithFrame:CGRectMake(self.giftView5.right+giftWidthSpace, self.giftView5.top, giftWidth, giftHeight)];
self.giftView6.delegate = self;
[self.giftContentView addSubview:self.giftView6];
[self.giftViewArray addObject:self.giftView1];
[self.giftViewArray addObject:self.giftView2];
[self.giftViewArray addObject:self.giftView3];
[self.giftViewArray addObject:self.giftView4];
[self.giftViewArray addObject:self.giftView5];
[self.giftViewArray addObject:self.giftView6];
// self.playAudioBtn = [[QXBadgeButton alloc] init];
// self.playAudioBtn.tag = 20;
// [self.playAudioBtn setImage:[UIImage imageNamed:@"room_event_play_audio_nor"] forState:(UIControlStateNormal)];
// [self.playAudioBtn setImage:[UIImage imageNamed:@"room_event_play_audio_sel"] forState:(UIControlStateSelected)];
// [self.playAudioBtn addTarget:self action:@selector(eventAction:) forControlEvents:(UIControlEventTouchUpInside)];
// self.playAudioBtn.hidden = YES;
// [self addSubview:self.playAudioBtn];
//
//
// self.audioBtn = [[QXBadgeButton alloc] init];
// self.audioBtn.tag = 21;
// [self.audioBtn setImage:[UIImage imageNamed:@"room_event_mute_audio_nor"] forState:(UIControlStateNormal)];
// [self.audioBtn setImage:[UIImage imageNamed:@"room_event_mute_audio_sel"] forState:(UIControlStateSelected)];
}
-(void)setRoomModel:(QXRoomModel *)roomModel{
_roomModel = roomModel;
QXRoomPitModel *pit1 = [[QXRoomPitModel alloc] init];
QXRoomPitModel *pit2 = [[QXRoomPitModel alloc] init];;
if ([roomModel.cp_user.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) {
pit1.user_id = roomModel.cp_user.user_id;
pit1.nickname = roomModel.cp_user.nickname;
pit1.dress = roomModel.cp_user.dress;
pit1.avatar = roomModel.cp_user.avatar;
pit2.user_id = roomModel.cp_user.user_id1;
pit2.nickname = roomModel.cp_user.nickname1;
pit2.dress = roomModel.cp_user.dress1;
pit2.avatar = roomModel.cp_user.avatar1;
}else{
pit2.user_id = roomModel.cp_user.user_id;
pit2.nickname = roomModel.cp_user.nickname;
pit2.dress = roomModel.cp_user.dress;
pit2.avatar = roomModel.cp_user.avatar;
pit1.user_id = roomModel.cp_user.user_id1;
pit1.nickname = roomModel.cp_user.nickname1;
pit1.dress = roomModel.cp_user.dress1;
pit1.avatar = roomModel.cp_user.avatar1;
}
self.leftSeatView.pitModel = pit1;
self.rightSeatView.pitModel = pit2;
[self.leftSeatView hideCharm];
[self.rightSeatView hideCharm];
self.titleLabel.text = self.roomModel.room_info.room_name;
self.numberLabel.text = self.roomModel.room_info.hot_value;
[self startTimer];
[self getGiftList];
}
-(void)rechargeSuccess{
[self getWallet];
}
-(void)getGiftList{
MJWeakSelf
// [QXMineNetwork giftListWithLabel:@"99" roomId:self.roomModel.room_info.room_id successBlock:^(NSArray<QXGiftModel *> * _Nonnull list) {
// [weakSelf.dataArray removeAllObjects];
// [weakSelf.dataArray addObjectsFromArray:list];
// for (int i = 0; i < list.count; i++) {
// if (i < 6) {
// QXRoomSeatBarCabinGiftView *giftView = self.giftViewArray[i];
// QXGiftModel *gift = list[i];
// giftView.giftModel = gift;
// [giftView startFloating];
// }
// }
// } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
//
// }];
// MJWeakSelf
[QXMineNetwork getRoomNewGiftListWithLabel:@"16" type:@"6" successBlock:^(NSArray<QXGiftModel *> * _Nonnull list) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.dataArray addObjectsFromArray:list];
for (int i = 0; i < list.count; i++) {
if (i < 6) {
QXRoomSeatBarCabinGiftView *giftView = self.giftViewArray[i];
QXGiftModel *gift = list[i];
giftView.giftModel = gift;
[giftView startFloating];
}
}
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(void)didSendGiftWithGiftModel:(QXGiftModel *)giftModel giftView:(QXRoomSeatBarCabinGiftView *)giftView{
if (self.isNoAlert) {
[self sendGiftNetWorkWithGiftModel:giftModel giftView:giftView];
}else{
QXSeductionAlertView *seductionView = [[QXSeductionAlertView alloc] init];
seductionView.alertType = QXSeductionAlertTypeSendGift;
seductionView.roomId = self.roomModel.room_info.room_id;
seductionView.giftModel = giftModel;
[seductionView showInView:self.viewController.view];
__weak typeof(self) weakSelf = self;
seductionView.commitBlock = ^(BOOL isNoAlert) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) return;
strongSelf.isNoAlert = isNoAlert;
[strongSelf sendGiftNetWorkWithGiftModel:giftModel giftView:giftView];
};
}
}
-(void)sendGiftNetWorkWithGiftModel:(QXGiftModel*)giftModel giftView:(QXRoomSeatBarCabinGiftView *)giftView{
NSString *to_uid = @"";
if ([self.roomModel.cp_user.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) {
to_uid = self.roomModel.cp_user.user_id1;
}else{
to_uid = self.roomModel.cp_user.user_id;
}
__weak typeof(self) weakSelf = self;
[QXMineNetwork roomSendGiftWithRoomId:self.roomModel.room_info.room_id gift_id:giftModel.gift_id gift_num:@"1" to_uid:to_uid heart_id:@"" type:@"1" pit_number:@"" gift_bag_id:giftModel.gift_bag successBlock:^(NSDictionary * _Nonnull dict) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) return;
[strongSelf getWallet];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
[giftView stopFloatingAnimation];
[UIView animateWithDuration:0.3 animations:^{
giftView.alpha = 0;
} completion:^(BOOL finished) {
[self giftViewShow:giftView];
}];
}
-(void)getWallet{
__weak typeof(self) weakSelf = self;
[QXMineNetwork getWalletInfoSuccessBlock:^(NSString * _Nonnull coin, NSString * _Nonnull earnings, NSString * _Nonnull title, NSString * _Nonnull url) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) return;
QXRoomViewController *vc = (QXRoomViewController *)strongSelf.viewController;
vc.coinLabel.text = coin;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(void)giftViewShow:(QXRoomSeatBarCabinGiftView*)giftView{
QXGiftModel *gift = [self randomResultGift];
giftView.giftModel = gift;
[UIView animateWithDuration:0.3 animations:^{
giftView.alpha = 1;
} completion:^(BOOL finished) {
[giftView startFloating];
}];
}
-(QXGiftModel*)randomResultGift{
NSUInteger randomIndex = arc4random() % self.dataArray.count;
QXGiftModel *result = self.dataArray[randomIndex];
return result;
}
-(void)cabinRoomHotValueDidChanged:(NSString *)hot_value{
self.roomModel.room_info.hot_value = hot_value;
self.numberLabel.text = self.roomModel.room_info.hot_value;
}
-(void)friendCabinRoomTimeDelayWithTime:(NSString*)end_time{
self.roomModel.cp_user.time_day = end_time;
[self stopTimer];
[self startTimer];
}
-(void)friendCabinRoomIsQuit{
}
-(void)startTimer{
MJWeakSelf
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
// 将秒转换为毫秒
long long milliseconds = (long long)(timeInterval);
self.startTime = self.roomModel.cp_user.time_day.longLongValue - milliseconds;
if (self.startTime <= 0) {
//时间错误不进行倒计时
self.timeDownLabel.text = @"倒计时00:00:00";
return;
}
[self stopTimer];
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.startTime--;
NSInteger hour = self.startTime/60/60;
NSInteger min = (self.startTime % 3600) / 60;
NSInteger second = self.startTime % 60;
weakSelf.timeDownLabel.text = [NSString stringWithFormat:@"倒计时:%02ld:%02ld:%02ld",hour,min,(long)second];
if (weakSelf.startTime<=0) {
[weakSelf stopTimer];
weakSelf.timeDownLabel.text = @"00:00:00";
}
});
}];
}
-(void)stopTimer{
if (_timer) {
[self->_timer invalidate];
self->_timer= nil;
}
}
-(void)closeAction{
MJWeakSelf
UIAlertController *al = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];
// [al addAction:[UIAlertAction actionWithTitle:@"最小化房间" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
// [weakSelf miniRoom];
// [[QXGlobal shareGlobal] miniRoomWithRoomId:weakSelf.roomModel.room_info.room_id roomCover:weakSelf.roomModel.room_info.room_cover];
// }]];
[al addAction:[UIAlertAction actionWithTitle:@"退出房间" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
[weakSelf leaveRoom];
}]];
[al addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
}]];
[self.viewController presentViewController:al animated:YES completion:nil];
}
-(void)leaveRoom{
UINavigationController *na = (UINavigationController *)KEYWINDOW.rootViewController;
if ([self.roomModel.room_info.type_id isEqualToString:@"6"] && [self.roomModel.room_info.label_id isEqualToString:@"11"]) {
[[QXGlobal shareGlobal] quitRoomWithRoomId:self.roomModel.room_info.room_id removeListener:YES];
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:na.viewControllers];
for (int i = 0; i < viewControllers.count; i++) {
UIViewController *vc = [viewControllers objectAtIndex:i];
if ([vc isEqual:self.viewController]) {
QXRoomViewController *roomVc = [[QXRoomViewController alloc] init];
roomVc.roomId = QXGlobal.shareGlobal.superRoomId;
[viewControllers insertObject:roomVc atIndex:i];
QXGlobal.shareGlobal.roomVC = roomVc;
QXGlobal.shareGlobal.roomId = roomVc.roomId;
break;
}
}
[UIApplication sharedApplication].idleTimerDisabled = YES;
na.viewControllers = viewControllers;
[na popViewControllerAnimated:YES];
QXGlobal.shareGlobal.superRoomId = @"";
[[QXRoomMessageManager shared] quitExGroup];
}else{
[[QXGlobal shareGlobal]quitRoomWithRoomId:self.roomModel.room_info.room_id removeListener:YES];
// self.navigationController.interactivePopGestureRecognizer.enabled = YES;
[na popViewControllerAnimated:YES];
}
}
-(void)stopHWDMP4{
[self.leftSeatView stopHWDMP4];
[self.rightSeatView stopHWDMP4];
}
-(void)playHWDMP4{
[self.leftSeatView playHWDMP4];
[self.rightSeatView playHWDMP4];
}
-(void)destroyViews{
if (_leftSeatView) {
[_leftSeatView destroyViews];
_leftSeatView = nil;
}
if (_rightSeatView) {
[_rightSeatView destroyViews];
_rightSeatView = nil;
}
[self stopTimer];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(NSMutableArray *)dataArray{
if (!_dataArray) {
_dataArray = [NSMutableArray array];
}
return _dataArray;
}
-(NSMutableArray *)giftViewArray{
if (!_giftViewArray) {
_giftViewArray = [NSMutableArray array];
}
return _giftViewArray;
}
@end
@implementation QXRoomSeatBarCabinGiftView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)setGiftModel:(QXGiftModel *)giftModel{
_giftModel = giftModel;
[self.giftCoinBtn setTitle:giftModel.gift_price forState:(UIControlStateNormal)];
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:giftModel.base_image]];
if (giftModel.gift_price.intValue<101) {
[self.giftBgImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(45);
make.centerX.equalTo(self);
make.top.equalTo(self);
}];
[self.giftImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.giftBgImageView).offset(11);
make.right.equalTo(self.giftBgImageView).offset(-11);
make.height.equalTo(self.giftImageView.mas_width);
}];
[self.giftCoinBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.top.equalTo(self.giftBgImageView.mas_bottom);
make.height.mas_equalTo(16);
}];
return;
}else if (giftModel.gift_price.intValue > 100 && giftModel.gift_price.intValue < 501){
[self.giftBgImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(60);
make.centerX.equalTo(self);
make.top.equalTo(self);
}];
[self.giftImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.giftBgImageView).offset(11);
make.right.equalTo(self.giftBgImageView).offset(-11);
make.height.equalTo(self.giftImageView.mas_width);
}];
[self.giftCoinBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.top.equalTo(self.giftBgImageView.mas_bottom);
make.height.mas_equalTo(16);
}];
return;
}else{
[self.giftBgImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.equalTo(self);
make.height.equalTo(self.giftBgImageView.mas_width);
}];
[self.giftImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.giftBgImageView).offset(11);
make.right.equalTo(self.giftBgImageView).offset(-11);
make.height.equalTo(self.giftImageView.mas_width);
}];
[self.giftCoinBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.top.equalTo(self.giftBgImageView.mas_bottom);
make.height.mas_equalTo(16);
}];
}
}
-(void)giftAction:(UIButton*)sender{
if (self.delegate && [self.delegate respondsToSelector:@selector(didSendGiftWithGiftModel:giftView:)]) {
[self.delegate didSendGiftWithGiftModel:self.giftModel giftView:self];
}
}
-(void)initSubviews{
self.giftBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bar_room_cabin_gift_bg"]];
self.giftBgImageView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:self.giftBgImageView];
[self.giftBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.equalTo(self);
make.height.equalTo(self.giftBgImageView.mas_width);
}];
self.giftImageView = [[UIImageView alloc] init];
self.giftImageView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:self.giftImageView];
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.giftBgImageView).offset(11);
make.right.mas_equalTo(-11);
make.height.equalTo(self.giftImageView.mas_width);
}];
self.giftCoinBtn = [[UIButton alloc] init];
self.giftCoinBtn.userInteractionEnabled = NO;
[self.giftCoinBtn setImage:[UIImage imageNamed:@"mine_live_gift_corn"] forState:(UIControlStateNormal)];
[self.giftCoinBtn setTitleColor:RGB16(0xDBEB23) forState:(UIControlStateNormal)];
[self.giftCoinBtn setTitle:@"0" forState:(UIControlStateNormal)];
self.giftCoinBtn.titleLabel.font = [UIFont systemFontOfSize:12];
[self addSubview:self.giftCoinBtn];
[self.giftCoinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.top.equalTo(self.giftBgImageView.mas_bottom);
make.height.mas_equalTo(16);
}];
self.button = [[UIButton alloc] init];
[self.button addTarget:self action:@selector(giftAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.button];
[self.button mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.top.equalTo(self);
}];
}
@end