123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- //
- // YOUPAILCGiftSendView.m
- // LiveChat
- //
- // Created by 张灿 on 2018/9/29.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCGiftSendView.h"
- @interface YOUPAILCGiftSendView()
- @property(nonatomic,strong)YOUPAILCGiftModel* youpaipgiftModel;
- @property (nonatomic,strong)UIControl *youpaipbackControl;
- @property (nonatomic,strong)UIView *youpaipmenuView;
- @property (nonatomic,strong)UILabel* youpaipcenterL;
- @end
- @implementation YOUPAILCGiftSendView
- - (UIWindow*)youpaipalertWindow{
- if (!_youpaipalertWindow) {
- _youpaipalertWindow = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
- _youpaipalertWindow.windowLevel = UIWindowLevelAlert+1;
- }
- return _youpaipalertWindow;
- }
- -(instancetype)initWithModel:(YOUPAILCGiftModel*)model type:(NSInteger)type{
- if (self = [super init]) {
- self.youpaiptype = type;
- self.youpaipgiftModel = model;
- [self youpaifsetupView];
- }
- return self;
- }
- - (void)youpaifsetupView{
-
- self.frame = [UIScreen mainScreen].bounds;
- UIControl *control = [[UIControl alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
- [control addTarget:self action:@selector(hide) forControlEvents:UIControlEventTouchUpInside];
- control.backgroundColor = [UIColor clearColor];
- self.youpaipbackControl = control;
- [self addSubview:control];
-
- UIView* menuView = [[UIView alloc]initWithFrame:CGRectMake(32.0f, -KScreenHeight, KScreenWidth-64.0f, 271.0f)];
- menuView.backgroundColor = HexColorFromRGB(0x2A2935);
- menuView.layer.cornerRadius = 10.0f;
- menuView.layer.masksToBounds = YES;
- menuView.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
- menuView.layer.borderWidth = 0.5f;
- self.youpaipmenuView = menuView;
- [self addSubview:menuView];
-
-
- UIButton* cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 43.0f, 43.0f)];
- [cancelBtn setImage:[UIImage imageNamed:@"vqu_images_H_home_gift_send_close"] forState:UIControlStateNormal];
- [cancelBtn setImage:[UIImage imageNamed:@"vqu_images_H_home_gift_send_close"] forState:UIControlStateHighlighted];
- [cancelBtn addTarget:self action:@selector(youpaifcancelBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [menuView addSubview:cancelBtn];
-
-
-
-
- UIImageView* imgV = [[UIImageView alloc]initWithFrame:CGRectMake((menuView.mj_w - 85.0f) / 2.0f, 25.0f, 85.0f, 85.0f)];
- imgV.contentMode = UIViewContentModeScaleAspectFill;
- [menuView addSubview:imgV];
-
- UILabel* tipLabel = [[UILabel alloc]initWithFrame:CGRectMake(30.0f, CGRectGetMaxY(imgV.frame) + 5.0f, menuView.mj_w - 60.0f, 14.0f)];
- tipLabel.textAlignment = NSTextAlignmentCenter;
- tipLabel.font = LCFont12;
- tipLabel.textColor = [UIColor whiteColor];
- [menuView addSubview:tipLabel];
-
- if (self.youpaiptype==1) {
- tipLabel.text = @"赠送玫瑰花";
- imgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_gift_send"];
- }else{
- tipLabel.text = [NSString stringWithFormat:@"赠送%@",self.youpaipgiftModel.youpaipname];
- imgV.image = [LCTools giftImgWithGiftUrlStr:self.youpaipgiftModel.youpaipimg];
- }
-
- UIView* countView = [[UIView alloc]initWithFrame:CGRectMake((menuView.mj_w - 105.0f) / 2.0f, CGRectGetMaxY(tipLabel.frame) + 10.0f, 105.0f, 28.0f)];
- countView.backgroundColor = HexColorFromRGB(0x4F4B5B);
- countView.layer.cornerRadius = 14.0f;
- countView.layer.masksToBounds = YES;
- [menuView addSubview:countView];
-
- UIButton* leftBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 28.0f)];
- leftBtn.titleLabel.font = LCFont14;
- [leftBtn setTitle:@"-" forState:(UIControlStateNormal)];
- [leftBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- leftBtn.adjustsImageWhenHighlighted = NO;
- [leftBtn setEnlargeEdge:20];
- [leftBtn addTarget:self action:@selector(youpaifleftBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [countView addSubview:leftBtn];
-
- UIButton* rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(65.0f, 0, 40, 28.0f)];
- rightBtn.titleLabel.font = LCFont14;
- [rightBtn setTitle:@"+" forState:(UIControlStateNormal)];
- [rightBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- rightBtn.adjustsImageWhenHighlighted = NO;
- [rightBtn setEnlargeEdge:20];
- [rightBtn addTarget:self action:@selector(youpaifrightBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [countView addSubview:rightBtn];
-
- UILabel* centerL = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 25.0f, 28.0f)];
- centerL.textAlignment = NSTextAlignmentCenter;
- centerL.textColor = [UIColor whiteColor];
- centerL.font = LCFont(14);
- centerL.text = @"1";
- [countView addSubview:centerL];
- self.youpaipcenterL = centerL;
-
-
-
- UIButton* confirmBtn = [[UIButton alloc]initWithFrame:CGRectMake(30.0f, CGRectGetMaxY(countView.frame) + 36.0f, menuView.mj_w - 60.0f, 48.0f)];
- confirmBtn.titleLabel.font = LCFont(17);
- confirmBtn.layer.cornerRadius = 24.0f;
- confirmBtn.clipsToBounds = YES;
- [confirmBtn setBackgroundImage:[LCTools ColorImage:confirmBtn.mj_size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
- [confirmBtn setTitle:@"确定" forState:(UIControlStateNormal)];
- [confirmBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- confirmBtn.adjustsImageWhenHighlighted = NO;
- [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [menuView addSubview:confirmBtn];
-
-
-
- }
- - (void)youpaifleftBtnClick{
- if ([self.youpaipcenterL.text integerValue]>1) {
- self.youpaipcenterL.text = [NSString stringWithFormat:@"%zd",[self.youpaipcenterL.text integerValue]-1];
- }
- }
- - (void)youpaifrightBtnClick{
- if ([self.youpaipcenterL.text integerValue]<99) {
- self.youpaipcenterL.text = [NSString stringWithFormat:@"%zd",[self.youpaipcenterL.text integerValue]+1];
- }
- }
- - (void)youpaifcancelBtnClick{
- [self youpaifhide];
- }
- - (void)youpaifconfirmBtnClick{
- if (self.youpaipsendMultiGift) {
- [self youpaifhide];
- if (self.youpaiptype==1) {
- self.youpaipsendMultiGift(@"", [self.youpaipcenterL.text integerValue]);
- }else{
- self.youpaipsendMultiGift(self.youpaipgiftModel.youpaipid, [self.youpaipcenterL.text integerValue]);
- }
- }
- }
- - (void)youpaifshow{
- _youpaipalertWindow.hidden = NO;
- [_youpaipalertWindow addSubview:self];
- self.youpaipbackControl.backgroundColor = HexColorFromRGBA(0x000000, 0.3);
- [UIView animateWithDuration:0.25 animations:^{
- self.youpaipmenuView.frame = CGRectMake(32.0f, (KScreenHeight - 271.0f)/2, KScreenWidth-64.0f, 271.0f);
- } completion:^(BOOL finished) {
-
- }];
- }
- - (void)youpaifhide{
- self.youpaipbackControl.backgroundColor = [UIColor clearColor];
- [UIView animateWithDuration:0.25 animations:^{
- self.youpaipmenuView.frame = CGRectMake(32.0f, -KScreenHeight, KScreenWidth-64.0f, 271.0f);
- } completion:^(BOOL finished) {
- [self removeFromSuperview];
- _youpaipalertWindow.hidden = YES;
- _youpaipalertWindow = nil;
-
- }];
- }
- @end
|