123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- //
- // XYLiveRoomChatInputView.m
- // Starbuds
- //
- // Created by pajia on 2020/1/7.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYLiveRoomChatInputView.h"
- #import "UITextView+KCPlaceHolder.h"
- #import "uiview_ViewControllerMethods.h"
- #import "UIViewController+KCTopViewController.h"
- #import "XYLiveRoomMessageInfo.h"
- #import "XYHeadlineRoomManage.h"
- @interface XYLiveRoomChatInputView ()<UITextViewDelegate>
- @property (nonatomic, strong) UIView *shadowView;
- @property (nonatomic, strong) UIView *textInputShadowView;
- //@property (nonatomic, strong) UITextView *textView;
- @property (nonatomic, strong) UIButton *sendBtn;
- @property (nonatomic, strong) UIButton *giftBtn;
- @property (nonatomic, strong) NSTimer *timer;
- //@property (nonatomic, strong) UIButton *emojiBtn;
- @property (nonatomic, strong) UIButton *headLineBtn;
- //@property (nonatomic, strong) UIButton *balanceBtn;
- @end
- @implementation XYLiveRoomChatInputView
- - (void)setup{
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidhidden:) name:UIKeyboardWillHideNotification object:nil];
-
- self.userInteractionEnabled = YES;
- self.hidden = YES;
- self.hiddenView.hidden = YES;
-
- [self hiddenView];
- [self shadowView];
- [self textView];
- [self sendBtn];
-
- if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
- [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- [self.shadowView addShadowPathWith:[UIColor colorWithHexString:@"#000000" alpha:0.1] shadowOpacity:3 shadowRadius:12 shadowSide:ShadowPathTop shadowPathWidth:8];
- self.shadowView.backgroundColor = [UIColor whiteColor];
- self.textInputShadowView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FA" alpha:1];
- [self showBottomItem];
-
- if (self.headLineActivity){
- self.headLineBtn.hidden = NO;
- self.balanceBtn.hidden = NO;
- [self headLineBtnAction];
-
- [self.textInputShadowView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headLineBtn.mas_right).offset(8);
- make.right.equalTo(self.shadowView.mas_right).offset(-66);
- make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
- make.height.offset(40);
- }];
-
- [self.textView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.textInputShadowView.mas_left).offset(10);
- make.right.equalTo(self.textInputShadowView.mas_right).offset(-40);
- make.centerY.equalTo(self.textInputShadowView.mas_centerY).offset(0);
- make.height.offset(40);
- }];
-
- [self.textInputShadowView addSubview:self.emojiBtn];
- [self.emojiBtn mas_remakeConstraints:^(MASConstraintMaker *make) {;
- make.right.equalTo(self.textInputShadowView.mas_right).offset(-10);
- make.centerY.equalTo(self.textInputShadowView.mas_centerY).offset(0);
- make.width.offset(20);
- make.height.offset(20);
- }];
-
- [self.sendBtn setTitle:@"" forState:UIControlStateNormal];
- [self.sendBtn setImage:[UIImage imageNamed:@"xy-headlineroom-iputsendnor"] forState:UIControlStateNormal];
- [self.sendBtn setImage:[UIImage imageNamed:@"xy-headlineroom-inputsendsel"] forState:UIControlStateSelected];
- self.sendBtn.adjustsImageWhenHighlighted = NO;
-
- }
-
- }else{
- self.shadowView.backgroundColor = [UIColor colorWithHexString:@"#F7F8FA" alpha:1];
- self.textInputShadowView.backgroundColor = [UIColor whiteColor];
-
- }
- }
- - (void)showBottomItem{
- self.hidden = NO;
- self.hiddenView.hidden = YES;
- self.emojiBtn.selected = NO;
- [self.textView resignFirstResponder];
-
- if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- self.giftBtn.hidden = NO;
- self.sendBtn.hidden = YES;
- }
- }
- - (void)showTopItem{
- self.hidden = NO;
- self.hiddenView.hidden = NO;
- self.emojiBtn.selected = YES;
- [self.textView becomeFirstResponder];
- if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- self.giftBtn.hidden = YES;
- self.sendBtn.hidden = NO;
- }
- }
- //输入数量
- - (void)show{
- if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
- [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- [self showTopItem];
- }else{//语音房间时
- self.hidden = NO;
- self.hiddenView.hidden = NO;
- [self.textView becomeFirstResponder];
- if (!self.inputGiftNum) {
- BOOL limtUser = [[XYChatRoomManager sharedInstance].chatRoomController.infoManager isLimitUser];
- if (limtUser) {
- self.textView.kc_maxWordInput = [NSNumber numberWithInt:50];
- }else{
- self.textView.kc_maxWordInput = [NSNumber numberWithInt:30];
- }
- }
- }
- }
- - (void)hide{
- if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
- [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- if (!self.hiddenView.hidden) { [self.textView resignFirstResponder]; }
- [self showBottomItem];
-
- }else{
- [self.textView resignFirstResponder];
- self.hidden = YES;
- self.hiddenView.hidden = YES;
- }
-
- [self timerAction];
- }
- - (void)hiddenViewTapAction{
- [self hide];
- }
- - (void)clear{
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
- [_timer invalidate];
- _timer = nil;
- [_hiddenView removeFromSuperview];
- _hiddenView = nil;
- }
- - (void)textViewDidChange:(UITextView *)textView{
- if (textView.text.length) {
- self.sendBtn.selected = YES;
- }else{
- self.sendBtn.selected = NO;
- }
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- if ([text isEqualToString:@"\n"]){
- [self sendBtnAction:nil];
- return NO;
- }
- return YES;
- }
- - (void)setAiteName:(NSString *)aiteName{
- _aiteName = aiteName;
- _textView.text = [NSString stringWithFormat:@"@%@ ", aiteName];
- }
- - (void)giftBtnAction{
- self.XYLiveMessageManagerBlock(nil);
- }
- - (void)sendBtnAction:(UIButton *)sender{
-
- if (self.inputGiftNum) {
- if (self.XYLiveMessageManagerBlock && self.textView.text.length) {
- NSDictionary *dataDict = @{@"giftNum":self.textView.text};
- self.XYLiveMessageManagerBlock(dataDict);
- self.textView.text = @"";
- self.sendBtn.selected = NO;
- _aiteName = nil;
- [self hiddenViewTapAction];
- }
-
- }else{
- if (!self.textView.text.length) {
- [SVProgressHUD showInfoWithStatus:@"消息不能为空"];
- return;
- }
-
- if (_timer) {
- [SVProgressHUD showInfoWithStatus:@"发送频率每秒一条"];
- return;
- }
-
- _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:NO];
- [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
-
- NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
- [dataDict setObject:[XYUserInfoManager nowUser].userId forKey:@"senderId"];
- [dataDict setObject:self.targetId forKey:@"targetId"];
-
- //senderProfile
- NSMutableDictionary *senderProfileDict = [[NSMutableDictionary alloc] init];
- [dataDict setObject:senderProfileDict forKey:@"senderProfile"];
- [senderProfileDict setObject:[XYUserInfoManager nowUser].userId forKey:@"userId"];
- [senderProfileDict setObject:[XYUserInfoManager nowUser].userAvatar forKey:@"userAvatar"];
- [senderProfileDict setObject:[XYUserInfoManager nowUser].userName forKey:@"userName"];
- [senderProfileDict setObject:[XYUserInfoManager nowUser].headWearAnimationId forKey:@"headWearAnimationId"];
- NSString *bubbleId = [XYUserInfoManager nowUser].bubbleId;
- if (StringIsNotEmpty(bubbleId)) {
- [senderProfileDict setObject:[XYUserInfoManager nowUser].bubbleId forKey:@"bubbleId"];
- }
- if ([XYUserInfoManager nowUser].isOfficial == 1) { [senderProfileDict setObject:@"99" forKey:@"userRole"]; }
- //
- if ([XYChatRoomManager sharedInstance].chatRoomController.infoManager.profile) {
- NSMutableDictionary *senderProfile = [NSMutableDictionary dictionaryWithDictionary:[XYChatRoomManager sharedInstance].chatRoomController.infoManager.profile];
- NSString *bubbleId = [XYUserInfoManager nowUser].bubbleId;
- if (StringIsNotEmpty(bubbleId)) {
- [senderProfile setObject:[XYUserInfoManager nowUser].bubbleId forKey:@"bubbleId"];
- }
- NSString *medalId = [XYUserInfoManager nowUser].medal.medalId;
- if (StringIsNotEmpty(medalId)) {
- [senderProfile setObject:[XYUserInfoManager nowUser].medal.medalId forKey:@"medalId"];
- }
- [dataDict setObject:senderProfile forKey:@"senderProfile"];
- }
-
- //msg
- NSMutableDictionary *msgDict = [[NSMutableDictionary alloc] init];
- [dataDict setObject:msgDict forKey:@"msg"];
- if([XYLiveManger shareInstance].liveRoomType == HeadLineRoom){
- [msgDict setObject:HEADLINE_MSG_TEXT forKey:@"type"];
- [dataDict setObject:HEADLINE_MSG_TEXT forKey:@"type"];
- }else if([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom){
- [msgDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
- [dataDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
- }else{
- [msgDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
- [dataDict setObject:LIVEROOM_MSG_TEXT forKey:@"type"];
- }
- if ([XYChatRoomManager sharedInstance].chatRoomController.infoManager.roomInfoModel.roomType == XYVoiceRoomTypeVoiceLive) {
- // 是否个播房间 1是个播房间
- [msgDict setObject:@(1) forKey:@"bType"];
- // 个播房场次id
- NSString *sessionID = [XYChatRoomManager sharedInstance].chatRoomController.infoManager.singleRtcHisId;
- if (StringIsNotEmpty(sessionID)) {
- [msgDict setObject:sessionID forKey:@"sessionID"];
- }
- }
- [msgDict setObject:[[SystemTimeObject getSystemTime] stringValue] forKey:@"timestamp"];
- //NSString *text = [self.textView.text stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"@%@ ", self.aiteName] withString:@""];
- //text = [text stringByReplacingOccurrencesOfString:self.aiteName withString:@""];
- [msgDict setObject:self.textView.text forKey:@"text"];
- if (self.aiteName) {
- [msgDict setObject:self.aiteUserId forKey:@"mentionUserId"];
- [dataDict setObject:@{@"userId":self.aiteUserId, @"userName":self.aiteName} forKey:@"mentionProfile"];
- }
- if (self.XYLiveMessageManagerBlock && self.textView.text.length) {
- self.XYLiveMessageManagerBlock(dataDict);
- self.textView.text = @"";
- self.sendBtn.selected = NO;
- _aiteName = nil;
- }
- }
-
- }
- - (void)keyboardDidShow:(NSNotification *)notification{
- if (self.hiddenView.hidden == YES) {return;}
-
- NSValue* aValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
- CGRect keyboardRect = [aValue CGRectValue];
- CGRect keyboardFrame = [self.viewController.view convertRect:keyboardRect fromView:[[UIApplication sharedApplication] keyWindow]];
- CGFloat keyboardHeight = keyboardFrame.size.height;
- if (self.XYLiveRoomChatInputViewStatusBlock) {
- self.XYLiveRoomChatInputViewStatusBlock(YES, keyboardHeight);
- }
-
- }
- - (void)keyboardDidhidden:(NSNotification *)notification{
- if (self.hiddenView.hidden == YES) {return; }
- [self hide];
- if (self.XYLiveRoomChatInputViewStatusBlock) {
- self.XYLiveRoomChatInputViewStatusBlock(NO, 0);
- }
- }
- - (void)timerAction{
- [_timer invalidate];
- _timer = nil;
- }
- - (void)emojiBtnAction{
- if (self.XYLiveRoomChatInputViewEmojiBntBlock) {
- if (self.emojiBtn.isSelected) {
- self.XYLiveRoomChatInputViewEmojiBntBlock(2);
- if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- [self quickMatchRoomHide];
- }
- }else{
- self.emojiBtn.selected = YES;
- self.XYLiveRoomChatInputViewEmojiBntBlock(1);
- self.giftBtn.hidden = YES;
- self.sendBtn.hidden = NO;
- }
- }
- //self.emojiBtn.selected = !self.emojiBtn.selected;
- }
- - (void)quickMatchRoomHide{
- if ([XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- self.giftBtn.hidden = NO;
- self.sendBtn.hidden = YES;
- }
- }
- - (void)headLineBtnAction{
- if (self.headLineBtn.isSelected) {
- self.headLineBtn.selected = NO;
- self.balanceBtn.selected = NO;
- kViewBorderRadius(self.headLineBtn, 10, 1, [UIColor colorWithHexString:@"#CCCCCC" alpha:1]);
-
- }else{
- self.headLineBtn.selected = YES;
- self.balanceBtn.selected = YES;
- kViewBorderRadius(self.headLineBtn, 10, 1, [UIColor colorWithHexString:@"#FF198C" alpha:1]);
- }
- }
- #pragma mark - lazy
- - (UIView *)shadowView{
- if (_shadowView == nil) {
- _shadowView = [[UIView alloc] init];
- [self addSubview:_shadowView];
- [_shadowView mas_makeConstraints:^(MASConstraintMaker *make) {;
- make.left.equalTo(self.mas_left).offset(0);
- make.bottom.equalTo(self.mas_bottom).offset(0);
- make.width.offset(kScreenWidth);
- make.height.offset(56);
- }];
- [_shadowView layoutIfNeeded];
- _shadowView.userInteractionEnabled = YES;
- }
- return _shadowView;
- }
- - (UIView *)hiddenView{
- if (_hiddenView == nil) {
- _hiddenView = [[UIView alloc] init];
- _hiddenView.backgroundColor = [UIColor clearColor];
- [self.showView addSubview:_hiddenView];
- [self.showView bringSubviewToFront:self];
- [_hiddenView mas_makeConstraints:^(MASConstraintMaker *make) {;
- make.left.equalTo(self.showView.mas_left).offset(0);
- make.top.equalTo(self.showView.mas_top).offset(0);
- make.width.offset(kScreenWidth);
- make.height.offset(kScreenHeight);
- }];
- [_hiddenView layoutIfNeeded];
- _hiddenView.hidden = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenViewTapAction)];
- _hiddenView.userInteractionEnabled = YES;
- [_hiddenView addGestureRecognizer:tap];
- }
- return _hiddenView;
- }
- - (UITextView *)textView{
- if (_textView == nil) {
-
- _textInputShadowView = [[UIView alloc] init];
- [self.shadowView addSubview:_textInputShadowView];
- [_textInputShadowView mas_makeConstraints:^(MASConstraintMaker *make) {
- // if ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
- // [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) {
- // make.left.equalTo(self.emojiBtn.mas_right).offset(10);
- // }else{
- // make.left.equalTo(self.shadowView.mas_left).offset(20);
- // }
- make.left.equalTo(self.shadowView.mas_left).offset(20);
- make.right.equalTo(self.shadowView.mas_right).offset(-56);
- make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
- make.height.offset(40);
- }];
-
- _textView = [[UITextView alloc] init];
- _textView.backgroundColor = [UIColor clearColor];
- _textView.kc_placeHolderColor = UIColorFromRGB(0x909399);
- _textView.kc_placeHolderFont = [UIFont fontWithName:kPFSCFont size:16];
- _textView.delegate = self ;
- _textView.textColor = UIColorFromRGB(0x303133);
- _textView.font = RegularFont(16);
- if (self.inputGiftNum) {
- _textView.kc_placeHolder = @"";
- _textView.keyboardType = UIKeyboardTypeNumberPad;
- _textView.textAlignment = NSTextAlignmentCenter;
- _textView.kc_maxWordInput = [NSNumber numberWithInt:5];
- }else{
- _textView.kc_placeHolder = kLocalizedString(@"说点什么吧~");
- _textView.kc_maxWordInput = [NSNumber numberWithInt:50];
- _textView.returnKeyType = UIReturnKeySend;
- }
- if (self.headLineActivity) {
- _textView.kc_maxWordInput = [NSNumber numberWithInt:30];
- }
- [_textInputShadowView addSubview:_textView];
- [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_textInputShadowView.mas_left).offset(10);
- make.right.equalTo(_textInputShadowView.mas_right).offset(-10);
- make.centerY.equalTo(_textInputShadowView.mas_centerY).offset(0);
- make.height.offset(40);
- }];
-
- kViewRadius(_textInputShadowView, 20);
-
- }
- return _textView ;
- }
- - (UIButton *)headLineBtn{
- if (_headLineBtn == nil) {
- _headLineBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_headLineBtn setTitle:kLocalizedString(@"头条") forState:UIControlStateNormal];
- [_headLineBtn setTitleColor:[UIColor colorWithHexString:@"#CCCCCC" alpha:1] forState:UIControlStateNormal];
- [_headLineBtn setTitleColor:[UIColor colorWithHexString:@"#FF198C" alpha:1] forState:UIControlStateSelected];
- _headLineBtn.titleLabel.font = [UIFont fontWithName:kPFSCFont size:12];
- _headLineBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
- _headLineBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
- _headLineBtn.titleLabel.minimumScaleFactor = 0.5;
- [_headLineBtn addTarget:self action:@selector(headLineBtnAction) forControlEvents:UIControlEventTouchUpInside];
- _headLineBtn.selected = NO;
- _headLineBtn.hidden = YES;
- [self.shadowView addSubview:_headLineBtn];
- [_headLineBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
- make.left.equalTo(self.shadowView.mas_left).offset(8);
- make.top.equalTo(self.shadowView.mas_top).offset(10);
- make.width.offset(36);
- make.height.offset(20);
- }];
- [_headLineBtn layoutIfNeeded];
- kViewBorderRadius(_headLineBtn, 10, 1, [UIColor colorWithHexString:@"#CCCCCC" alpha:1]);
- }
- return _headLineBtn;
- }
- - (UIButton *)balanceBtn{
- if (_balanceBtn == nil) {
- _balanceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_balanceBtn setTitle:[NSString stringWithFormat:@"%@钻石/次",@""] forState:UIControlStateNormal];
- if ([[XYHeadlineRoomManage shareInstance].headlineInfo.price integerValue] > 0) {
- [_balanceBtn setTitle:[NSString stringWithFormat:@"%@钻石/次",[XYHeadlineRoomManage shareInstance].headlineInfo.price] forState:UIControlStateNormal];
- }
- [_balanceBtn setTitleColor:[UIColor colorWithHexString:@"#CCCCCC" alpha:1] forState:UIControlStateNormal];
- [_balanceBtn setTitleColor:[UIColor colorWithHexString:@"#FF198C" alpha:1] forState:UIControlStateSelected];
- _balanceBtn.titleLabel.font = [UIFont fontWithName:kPFSCFont size:8];
- _balanceBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
- _balanceBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
- _balanceBtn.titleLabel.minimumScaleFactor = 0.5;
- [_balanceBtn addTarget:self action:@selector(headLineBtnAction) forControlEvents:UIControlEventTouchUpInside];
- _balanceBtn.selected = NO;
- _balanceBtn.hidden = YES;
- [self.shadowView addSubview:_balanceBtn];
- [_balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
- make.left.equalTo(self.shadowView.mas_left).offset(0);
- make.top.equalTo(self.headLineBtn.mas_bottom).offset(1);
- make.width.offset(52);
- make.height.offset(12);
- }];
- [_balanceBtn layoutIfNeeded];
- }
- return _balanceBtn;
- }
- - (UIButton *)emojiBtn{
- // if (_emojiBtn == nil && ([XYLiveManger shareInstance].liveRoomType == HeadLineRoom ||
- // [XYLiveManger shareInstance].liveRoomType == QuickMatchingRoom) ) {
- // _emojiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // [_emojiBtn setImage:[UIImage imageNamed:@"xy-headlineroom-emojibtn"] forState:UIControlStateNormal];
- // [_emojiBtn setImage:[UIImage imageNamed:@"xy-headlineroom-dowmbtn"] forState:UIControlStateSelected];
- // [_emojiBtn addTarget:self action:@selector(emojiBtnAction) forControlEvents:UIControlEventTouchUpInside];
- // [self.shadowView addSubview:_emojiBtn];
- // [_emojiBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
- // make.left.equalTo(self.shadowView.mas_left).offset(18);
- // make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
- // make.width.offset(20);
- // make.height.offset(20);
- // }];
- // [_emojiBtn layoutIfNeeded];
- // }
- return _emojiBtn;
- }
- - (UIButton *)sendBtn{
- if (_sendBtn == nil) {
- _sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- if (self.inputGiftNum) {
- [_sendBtn setTitle:kLocalizedString(@"确定") forState:UIControlStateNormal];
- }else{
- [_sendBtn setTitle:kLocalizedString(@"发送") forState:UIControlStateNormal];
- }
- [_sendBtn setTitleColor:[UIColor colorWithHexString:@"#606266" alpha:1] forState:UIControlStateNormal];
- _sendBtn.titleLabel.font = [UIFont fontWithName:kPFSCFont size:18];
- _sendBtn.titleLabel.textAlignment = NSTextAlignmentRight;
- _sendBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
- _sendBtn.titleLabel.minimumScaleFactor = 0.5;
- [_sendBtn addTarget:self action:@selector(sendBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.shadowView addSubview:_sendBtn];
- [_sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
- make.right.equalTo(self.shadowView.mas_right).offset(-10);
- make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
- make.width.offset(56);
- make.height.offset(56);
- }];
- [_sendBtn layoutIfNeeded];
- }
- return _sendBtn;
- }
- - (UIButton *)giftBtn{
- if (_giftBtn == nil) {
- _giftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_giftBtn setImage:[UIImage imageNamed:@"xy-icon-gift"] forState:UIControlStateNormal];
- [_giftBtn addTarget:self action:@selector(giftBtnAction) forControlEvents:UIControlEventTouchUpInside];
- [self.shadowView addSubview:_giftBtn];
- [_giftBtn mas_makeConstraints:^(MASConstraintMaker *make) {;
- make.right.equalTo(self.shadowView.mas_right).offset(-16);
- make.centerY.equalTo(self.shadowView.mas_centerY).offset(0);
- make.width.offset(40);
- make.height.offset(40);
- }];
- [_giftBtn layoutIfNeeded];
- }
- return _giftBtn;
- }
- @end
|