600 lines
22 KiB
Objective-C
600 lines
22 KiB
Objective-C
//
|
||
// XPGiftBottomView.m
|
||
// xplan-ios
|
||
//
|
||
// Created by 冯硕 on 2021/11/9.
|
||
//
|
||
|
||
#import "XPGiftBarView.h"
|
||
///Third
|
||
#import <Masonry/Masonry.h>
|
||
///Tool
|
||
#import "XPMacro.h"
|
||
#import "ThemeColor+SendGift.h"
|
||
#import "UIImage+Utils.h"
|
||
///Model
|
||
#import "XPGiftCountModel.h"
|
||
#import "WalletInfoModel.h"
|
||
///View
|
||
#import "XPGiftCountCollectionViewCell.h"
|
||
#import "XPGiftCountView.h"
|
||
#import "XPPrivilegeCardConfirmView.h"
|
||
@interface XPGiftBarView ()<UITextFieldDelegate, XPGiftCountViewDelegate>
|
||
|
||
///充值的背景
|
||
@property (nonatomic,strong) UIView *rechargeView;
|
||
@property (nonatomic,strong) UIStackView *rechargeStackView;
|
||
///余额
|
||
@property (nonatomic,strong) UILabel *balanceLabel;
|
||
///💎
|
||
@property (nonatomic,strong) UIImageView *diamondImageView;
|
||
///去充值
|
||
@property (nonatomic,strong) UIImageView *rechageImageView;
|
||
//赠送
|
||
@property (nonatomic,strong) UIStackView *sendOperationView;
|
||
///个数
|
||
@property (nonatomic,strong) UILabel *countLabel;
|
||
///箭头
|
||
@property (nonatomic,strong) UIButton *arrowButton;
|
||
///赠送
|
||
@property (nonatomic,strong) UIButton *sendGiftButton;
|
||
///自定义个数
|
||
@property (nonatomic,strong) UIView *customCountView;
|
||
//输入框
|
||
@property (nonatomic, strong) UITextField *editTextFiled;
|
||
//发送按钮
|
||
@property (nonatomic, strong) UIButton *sureButton;
|
||
///送礼物的个数
|
||
@property (nonatomic,strong) XPGiftCountView *giftCountView;
|
||
|
||
///特权数量
|
||
@property(nonatomic,strong) UILabel *privilegeNum;
|
||
|
||
///特权赠送
|
||
@property(nonatomic,strong) UIButton *privilegeSend;
|
||
|
||
|
||
@end
|
||
|
||
@implementation XPGiftBarView
|
||
|
||
- (void)dealloc {
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||
}
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame {
|
||
self = [super initWithFrame:frame];
|
||
if (self) {
|
||
[self initSubViews];
|
||
[self initSubViewConstraints];
|
||
[self addNotificationCenter];
|
||
[self initEvents];
|
||
}
|
||
return self;
|
||
}
|
||
#pragma mark - Response
|
||
- (void)sendButtonAction:(UIButton *)sender {
|
||
if (self.type == GiftSegmentType_Graffiti && self.drawGiftCount < 10) {
|
||
return;
|
||
}
|
||
if(self.type == GiftSegmentType_Privilege && self.privilegeArray.count == 0){
|
||
XPPrivilegeCardConfirmView *confirmView = [[XPPrivilegeCardConfirmView alloc]initInstructionsWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||
|
||
[TTPopup popupView:confirmView style:TTPopupStyleAlert];
|
||
return;
|
||
}
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftBarView:didClickSendGift:)]) {
|
||
[self.delegate xPGiftBarView:self didClickSendGift:self.giftCountModel];
|
||
}
|
||
}
|
||
|
||
- (void)didTagRecharge:(UITapGestureRecognizer *)tap {
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftBarViewDidClickRecharge:)]) {
|
||
[self.delegate xPGiftBarViewDidClickRecharge:self];
|
||
}
|
||
}
|
||
|
||
- (void)arrowButtonAction:(UIButton *)sender {
|
||
if (![[self.superview.superview subviews] containsObject:self.giftCountView]) {
|
||
[self.superview.superview addSubview:self.giftCountView];
|
||
|
||
[self.giftCountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.mas_equalTo(-15);
|
||
make.bottom.mas_equalTo(self.superview.superview.mas_bottom).offset(-45 -kSafeAreaBottomHeight);
|
||
make.width.mas_equalTo(135);
|
||
}];
|
||
}
|
||
[self updateCountStatus];
|
||
|
||
}
|
||
|
||
- (void)sureButtonAction:(UIButton *)sender {
|
||
NSString *countStr = [self.editTextFiled.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||
if (countStr.integerValue == 0) {
|
||
countStr = @"1";
|
||
}
|
||
[self.editTextFiled resignFirstResponder];
|
||
self.editTextFiled.text = @"";
|
||
self.giftCountModel.giftNumber = countStr;
|
||
self.countLabel.text = countStr;
|
||
}
|
||
|
||
- (void)firstRechargeButtonAction:(UIButton *)sender{
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftBarViewDidClickFirstRecharge:)]) {
|
||
[self.delegate xPGiftBarViewDidClickFirstRecharge:self];
|
||
}
|
||
}
|
||
|
||
#pragma mark - Private Method
|
||
- (void)initSubViews {
|
||
self.backgroundColor= [UIColor clearColor];
|
||
[self addSubview:self.rechargeView];
|
||
[self addSubview:self.sendOperationView];
|
||
|
||
[self.rechargeView addSubview:self.rechargeStackView];
|
||
|
||
[self.rechargeStackView addArrangedSubview:self.diamondImageView];
|
||
[self.rechargeStackView addArrangedSubview:self.balanceLabel];
|
||
[self.rechargeStackView addArrangedSubview:self.rechageImageView];
|
||
|
||
[self.sendOperationView addArrangedSubview:self.countLabel];
|
||
[self.sendOperationView addArrangedSubview:self.arrowButton];
|
||
[self.sendOperationView addArrangedSubview:self.sendGiftButton];
|
||
|
||
|
||
[self.customCountView addSubview:self.editTextFiled];
|
||
[self.customCountView addSubview:self.sureButton];
|
||
|
||
[self addSubview:self.privilegeNum];
|
||
[self addSubview:self.privilegeSend];
|
||
}
|
||
|
||
- (void)initSubViewConstraints {
|
||
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(45);
|
||
}];
|
||
[self.privilegeSend mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.trailing.mas_equalTo(-14);
|
||
make.width.mas_equalTo(60);
|
||
make.height.mas_equalTo(28);
|
||
make.bottom.mas_equalTo(-8.5);
|
||
}];
|
||
[self.privilegeNum mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.leading.mas_equalTo(14);
|
||
make.centerY.equalTo(self.privilegeSend);
|
||
}];
|
||
[self.rechargeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(self).offset(15);
|
||
make.height.mas_equalTo(32);
|
||
make.right.mas_equalTo(self.rechargeStackView.mas_right).offset(9);
|
||
make.centerY.mas_equalTo(self.sendGiftButton);
|
||
}];
|
||
|
||
[self.rechargeStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.bottom.mas_equalTo(self.rechargeView);
|
||
make.left.mas_equalTo(self.rechargeView).offset(9);
|
||
}];
|
||
|
||
[self.diamondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.mas_equalTo(CGSizeMake(14, 14));
|
||
}];
|
||
|
||
[self.rechageImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.mas_equalTo(CGSizeMake(15, 15));
|
||
}];
|
||
|
||
[self.sendOperationView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.mas_equalTo(self).offset(-15);
|
||
make.top.mas_equalTo(11);
|
||
make.height.mas_equalTo(32);
|
||
}];
|
||
|
||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.width.mas_equalTo(40);
|
||
make.height.mas_equalTo(30);
|
||
}];
|
||
|
||
|
||
[self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.mas_equalTo(CGSizeMake(30, 30));
|
||
}];
|
||
|
||
[self.sendGiftButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.size.mas_equalTo(CGSizeMake(60, 30));
|
||
}];
|
||
|
||
|
||
[self.editTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(self.customCountView).offset(15);
|
||
make.right.mas_equalTo(self.sureButton.mas_left).offset(-10);
|
||
make.top.bottom.mas_equalTo(self.customCountView);
|
||
}];
|
||
|
||
[self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(30);
|
||
make.width.mas_equalTo(@50);
|
||
make.centerY.mas_equalTo(self.customCountView);
|
||
make.right.mas_equalTo(self.customCountView).offset(-15);
|
||
}];
|
||
}
|
||
|
||
- (void)initEvents {
|
||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTagRecharge:)];
|
||
[self.rechargeStackView addGestureRecognizer:tap];
|
||
}
|
||
|
||
- (void)keyboardWillShow:(NSNotification *)notification {
|
||
CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||
CGFloat height = CGRectGetMinY(keyboardRect) - KScreenHeight;
|
||
if (height < 0) {
|
||
[UIView animateWithDuration:0.25 animations:^{
|
||
CGRect rect = self.customCountView.superview.superview.superview.frame;
|
||
rect.origin.y = height;
|
||
self.customCountView.superview.superview.superview.frame = rect;
|
||
}];
|
||
}
|
||
}
|
||
-(void)setPrivilegeCount:(NSString *)privilegeCount{
|
||
_privilegeCount = privilegeCount;
|
||
NSMutableAttributedString *countAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"今日剩余赠送次数:%@次",_privilegeCount] attributes:@{NSFontAttributeName:kFontRegular(12),NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||
[countAtt addAttributes:@{NSFontAttributeName:kFontMedium(12),NSForegroundColorAttributeName:UIColorFromRGB(0xFFDA24)} range:[countAtt.string rangeOfString:_privilegeCount]];
|
||
_privilegeNum.attributedText = countAtt;
|
||
}
|
||
//键盘隐藏
|
||
- (void)keyboardWillHidden:(NSNotification *)notification {
|
||
[UIView animateWithDuration:0.25 animations:^{
|
||
CGRect rect = self.customCountView.superview.superview.superview.frame;
|
||
rect.origin.y = 0;
|
||
self.customCountView.superview.superview.superview.frame = rect;
|
||
}];
|
||
self.customCountView.hidden = YES;
|
||
self.editTextFiled.text = @"";
|
||
}
|
||
|
||
- (void)addNotificationCenter {
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
|
||
}
|
||
|
||
- (void)updateCountStatus {
|
||
self.arrowButton.selected = !self.arrowButton.selected;
|
||
self.giftCountView.hidden = !self.arrowButton.selected;
|
||
}
|
||
|
||
#pragma mark - XPGiftCountViewDelegate
|
||
- (void)xPGiftCountView:(XPGiftCountView *)view didClickItem:(XPGiftCountModel *)model {
|
||
self.arrowButton.selected = NO;
|
||
self.giftCountView.hidden= YES;
|
||
self.giftCountModel = model;
|
||
if (model.isCustomCount) {
|
||
if (![[self.superview.superview subviews] containsObject:self.customCountView]) {
|
||
[self.superview.superview addSubview:self.customCountView];
|
||
|
||
[self.customCountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.bottom.mas_equalTo(self.superview.superview);
|
||
make.height.mas_equalTo(40);
|
||
}];
|
||
}
|
||
self.customCountView.hidden = NO;
|
||
[self.editTextFiled becomeFirstResponder];
|
||
}
|
||
}
|
||
|
||
#pragma mark - UITextFieldDelegate
|
||
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
||
NSString *countStr = [self.editTextFiled.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||
NSInteger count = [countStr integerValue];
|
||
if (count > 9999) {
|
||
return NO;
|
||
}
|
||
[self.editTextFiled resignFirstResponder];
|
||
self.editTextFiled.text = @"";
|
||
self.giftCountModel.giftNumber = textField.text;
|
||
return YES;
|
||
}
|
||
|
||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
||
NSString *regex =@"[0-9]*";
|
||
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
|
||
if ([pred evaluateWithObject:string]) {
|
||
return YES;
|
||
}
|
||
return NO;
|
||
}
|
||
#pragma mark - Getters And Setters
|
||
- (void)setUsingplaceType:(SendGiftType)usingplaceType {
|
||
_usingplaceType = usingplaceType;
|
||
if (_usingplaceType == SendGiftType_User) {
|
||
self.countLabel.textColor = [ThemeColor mainTextColor];
|
||
[self.arrowButton setImage:[UIImage imageNamed:@"gift_bar_white_count_arrow"] forState:UIControlStateNormal];
|
||
self.rechargeView.backgroundColor = UIColorRGBAlpha(0xFFE710, 0.3);
|
||
self.rechageImageView.image = [UIImage imageNamed:@"gift_bar_recharge_white_arrow"];
|
||
self.backgroundColor = [ThemeColor colorWithHexString:@"#FFFFFF"];
|
||
self.balanceLabel.textColor = [ThemeColor colorWithHexString:@"#282828"];
|
||
} else {
|
||
self.countLabel.textColor = [ThemeColor giftCountTitleColor];
|
||
[self.arrowButton setImage:[UIImage imageNamed:@"gift_bar_count_arrow"] forState:UIControlStateNormal];
|
||
self.rechargeView.backgroundColor = [ThemeColor colorWithHexString:@"#000000"];
|
||
self.rechageImageView.image = [UIImage imageNamed:@"gift_bar_recharge_arrow"];
|
||
self.backgroundColor = [UIColor clearColor];
|
||
self.balanceLabel.textColor = [ThemeColor colorWithHexString:@"#FFFFFF"];
|
||
}
|
||
}
|
||
|
||
- (void)setDrawGiftCount:(NSInteger)drawGiftCount {
|
||
_drawGiftCount = drawGiftCount;
|
||
if (_drawGiftCount >= 10) {
|
||
self.sendGiftButton.selected = NO;
|
||
self.sendOperationView.layer.borderWidth = 1;
|
||
self.sendOperationView.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||
} else {
|
||
self.sendGiftButton.selected = YES;
|
||
self.sendOperationView.layer.borderWidth = 1;
|
||
self.sendOperationView.layer.borderColor = [ThemeColor disableButtonColor].CGColor;
|
||
}
|
||
}
|
||
|
||
- (void)setSendButtonIsEnable:(BOOL)sendButtonIsEnable {
|
||
_sendButtonIsEnable = sendButtonIsEnable;
|
||
[UIView animateWithDuration:0.3 animations:^{
|
||
self.sendGiftButton.enabled = self.sendButtonIsEnable;
|
||
}];
|
||
}
|
||
- (void)setSendPrivileButtonIsEnable:(BOOL)sendPrivileButtonIsEnable{
|
||
_sendPrivileButtonIsEnable = sendPrivileButtonIsEnable;
|
||
[UIView animateWithDuration:0.3 animations:^{
|
||
self.privilegeSend.enabled = self.sendPrivileButtonIsEnable;
|
||
}];
|
||
}
|
||
-(void)setPrivilegeArray:(NSArray<XPPrivilegeCardItemModel *> *)privilegeArray{
|
||
_privilegeArray = privilegeArray;
|
||
if(_privilegeArray.count == 0){
|
||
[_privilegeSend setTitle:@"说明" forState:UIControlStateNormal];
|
||
[_privilegeSend setTitle:@"说明" forState:UIControlStateDisabled];
|
||
self.privilegeSend.enabled = YES;
|
||
self.privilegeNum.hidden = YES;
|
||
}else{
|
||
[_privilegeSend setTitle:@"赠送" forState:UIControlStateNormal];
|
||
[_privilegeSend setTitle:@"赠送中..." forState:UIControlStateDisabled];
|
||
self.privilegeNum.hidden = NO;
|
||
|
||
}
|
||
}
|
||
- (void)setIsShowFirstRecharge:(BOOL)isShowFirstRecharge {
|
||
|
||
}
|
||
|
||
- (void)setType:(GiftSegmentType)type {
|
||
_type = type;
|
||
|
||
if(self.type == GiftSegmentType_Privilege){
|
||
if(self.privilegeArray.count > 0 ){
|
||
self.privilegeNum.hidden = NO;
|
||
}
|
||
self.privilegeSend.hidden = NO;
|
||
self.rechargeView.hidden = YES;
|
||
self.sendOperationView.hidden = YES;
|
||
self.giftCountView.segmentType = type;
|
||
return;
|
||
}else{
|
||
self.privilegeNum.hidden = YES;
|
||
self.privilegeSend.hidden = YES;
|
||
self.rechargeView.hidden = NO;
|
||
self.sendOperationView.hidden = NO;
|
||
}
|
||
|
||
if (!self.giftCountView.hidden) {
|
||
self.giftCountView.hidden = YES;
|
||
self.arrowButton.selected = NO;
|
||
} else {
|
||
if (_type == GiftSegmentType_Graffiti) {
|
||
self.countLabel.hidden = YES;
|
||
self.arrowButton.hidden = YES;
|
||
} else {
|
||
self.countLabel.hidden = NO;
|
||
self.arrowButton.hidden = NO;
|
||
}
|
||
}
|
||
self.giftCountView.segmentType = type;
|
||
}
|
||
|
||
- (void)setGiftCountModel:(XPGiftCountModel *)giftCountModel {
|
||
_giftCountModel = giftCountModel;
|
||
self.arrowButton.selected = NO;
|
||
if (_giftCountModel) {
|
||
self.countLabel.text = _giftCountModel.giftNumber;
|
||
}
|
||
}
|
||
|
||
- (void)setWalletInfoModel:(WalletInfoModel *)walletInfoModel {
|
||
_walletInfoModel = walletInfoModel;
|
||
if (_walletInfoModel) {
|
||
NSString * diamonds = _walletInfoModel.diamonds;
|
||
self.balanceLabel.text = diamonds;
|
||
}
|
||
}
|
||
|
||
- (UIView *)rechargeView {
|
||
if (!_rechargeView) {
|
||
_rechargeView = [[UIView alloc] init];
|
||
_rechargeView.backgroundColor = [UIColor clearColor];
|
||
_rechargeView.layer.masksToBounds= YES;
|
||
_rechargeView.layer.cornerRadius = 16;
|
||
}
|
||
return _rechargeView;
|
||
}
|
||
|
||
- (UILabel *)balanceLabel {
|
||
if (!_balanceLabel) {
|
||
_balanceLabel = [[UILabel alloc] init];
|
||
_balanceLabel.textColor = [ThemeColor mainTextColor];
|
||
_balanceLabel.font = [UIFont systemFontOfSize:13];
|
||
}
|
||
return _balanceLabel;
|
||
}
|
||
|
||
- (UIStackView *)rechargeStackView {
|
||
if (!_rechargeStackView) {
|
||
_rechargeStackView = [[UIStackView alloc] init];
|
||
_rechargeStackView.axis = UILayoutConstraintAxisHorizontal;
|
||
_rechargeStackView.distribution = UIStackViewDistributionFill;
|
||
_rechargeStackView.alignment = UIStackViewAlignmentCenter;
|
||
_rechargeStackView.spacing = 3;
|
||
}
|
||
return _rechargeStackView;
|
||
}
|
||
|
||
- (UIImageView *)diamondImageView {
|
||
if (!_diamondImageView) {
|
||
_diamondImageView = [[UIImageView alloc] init];
|
||
_diamondImageView.userInteractionEnabled = YES;
|
||
_diamondImageView.image = [UIImage imageNamed:@"common_diamond"];
|
||
}
|
||
return _diamondImageView;
|
||
}
|
||
|
||
- (UIImageView *)rechageImageView {
|
||
if (!_rechageImageView) {
|
||
_rechageImageView = [[UIImageView alloc] init];
|
||
_rechageImageView.userInteractionEnabled = YES;
|
||
_rechageImageView.image = [UIImage imageNamed:@"gift_bar_recharge_arrow"];
|
||
}
|
||
return _rechageImageView;
|
||
}
|
||
|
||
|
||
- (UIStackView *)sendOperationView {
|
||
if (!_sendOperationView) {
|
||
_sendOperationView = [[UIStackView alloc] init];
|
||
_sendOperationView.axis = UILayoutConstraintAxisHorizontal;
|
||
_sendOperationView.distribution = UIStackViewDistributionFill;
|
||
_sendOperationView.alignment = UIStackViewAlignmentCenter;
|
||
_sendOperationView.spacing = 1;
|
||
_sendOperationView.layer.masksToBounds = YES;
|
||
_sendOperationView.layer.cornerRadius = 15;
|
||
_sendOperationView.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||
_sendOperationView.layer.borderWidth = 5;
|
||
}
|
||
return _sendOperationView;
|
||
}
|
||
|
||
|
||
- (UILabel *)countLabel {
|
||
if (!_countLabel) {
|
||
_countLabel = [[UILabel alloc] init];
|
||
_countLabel.textAlignment = NSTextAlignmentCenter;
|
||
_countLabel.textColor = [ThemeColor giftCountTitleColor];
|
||
_countLabel.text = @"1";
|
||
_countLabel.font = [UIFont systemFontOfSize:13];
|
||
_countLabel.textAlignment = NSTextAlignmentCenter;
|
||
}
|
||
return _countLabel;
|
||
}
|
||
|
||
- (UIButton *)arrowButton {
|
||
if (!_arrowButton) {
|
||
_arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_arrowButton setImage:[UIImage imageNamed:@"gift_bar_count_arrow"] forState:UIControlStateNormal];
|
||
[_arrowButton addTarget:self action:@selector(arrowButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
self.arrowButton.transform = CGAffineTransformMakeRotation(M_PI);
|
||
}
|
||
return _arrowButton;
|
||
}
|
||
|
||
- (UIButton *)sendGiftButton {
|
||
if (!_sendGiftButton) {
|
||
_sendGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_sendGiftButton setTitle:@"赠送" forState:UIControlStateNormal];
|
||
[_sendGiftButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
|
||
[_sendGiftButton setTitle:@"赠送中..." forState:UIControlStateDisabled];
|
||
[_sendGiftButton setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateDisabled];
|
||
[_sendGiftButton setTitle:@"赠送" forState:UIControlStateSelected];
|
||
[_sendGiftButton setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateSelected];
|
||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
||
[_sendGiftButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateSelected];
|
||
_sendGiftButton.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
||
_sendGiftButton.layer.masksToBounds = YES;
|
||
CAShapeLayer *layer = [CAShapeLayer layer];
|
||
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 67, 30) byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(15, 15)];
|
||
layer.path = path.CGPath;
|
||
_sendGiftButton.layer.mask = layer;
|
||
[_sendGiftButton addTarget:self action:@selector(sendButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _sendGiftButton;
|
||
}
|
||
- (UIButton *)privilegeSend{
|
||
if(!_privilegeSend){
|
||
_privilegeSend = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_privilegeSend setTitle:@"说明" forState:UIControlStateNormal];
|
||
[_privilegeSend setTitle:@"说明" forState:UIControlStateDisabled];
|
||
[_privilegeSend setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateDisabled];
|
||
[_privilegeSend setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
|
||
[_privilegeSend setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
||
_privilegeSend.layer.cornerRadius = 14;
|
||
_privilegeSend.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];;
|
||
[_privilegeSend setTitleColor:UIColorFromRGB(0x2B2D33) forState:UIControlStateNormal];
|
||
_privilegeSend.layer.masksToBounds = YES;
|
||
_privilegeSend.hidden = YES;
|
||
[_privilegeSend addTarget:self action:@selector(sendButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _privilegeSend;
|
||
}
|
||
|
||
- (UITextField *)editTextFiled {
|
||
if (!_editTextFiled) {
|
||
_editTextFiled = [[UITextField alloc] init];
|
||
NSAttributedString * attribute = [[NSAttributedString alloc] initWithString:@"请输入赠送数额" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[ThemeColor secondTextColor]}];
|
||
_editTextFiled.attributedPlaceholder = attribute;
|
||
_editTextFiled.borderStyle = UITextBorderStyleNone;
|
||
_editTextFiled.returnKeyType = UIReturnKeyDone;
|
||
_editTextFiled.delegate = self;
|
||
_editTextFiled.textColor = [ThemeColor secondTextColor];
|
||
_editTextFiled.keyboardType = UIKeyboardTypeNumberPad;
|
||
}
|
||
return _editTextFiled;
|
||
}
|
||
|
||
- (UIButton *)sureButton {
|
||
if (!_sureButton) {
|
||
_sureButton = [[UIButton alloc] init];
|
||
[_sureButton setTitle:@"确定" forState:UIControlStateNormal];
|
||
_sureButton.titleLabel.textColor = [ThemeColor mainTextColor];
|
||
_sureButton.titleLabel.font = [UIFont systemFontOfSize:15];
|
||
_sureButton.backgroundColor = [ThemeColor appMainColor];
|
||
_sureButton.layer.cornerRadius = 5.0;
|
||
_sureButton.layer.masksToBounds = YES;
|
||
[_sureButton addTarget:self action:@selector(sureButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _sureButton;
|
||
}
|
||
|
||
|
||
- (UIView *)customCountView {
|
||
if (!_customCountView) {
|
||
_customCountView = [[UIView alloc] init];
|
||
_customCountView.backgroundColor = [UIColor whiteColor];
|
||
}
|
||
return _customCountView;
|
||
}
|
||
|
||
- (XPGiftCountView *)giftCountView {
|
||
if (!_giftCountView) {
|
||
_giftCountView = [[XPGiftCountView alloc] init];
|
||
_giftCountView.delegate = self;
|
||
_giftCountView.hidden = YES;
|
||
}
|
||
return _giftCountView;
|
||
}
|
||
- (UILabel *)privilegeNum{
|
||
if(!_privilegeNum){
|
||
_privilegeNum = [UILabel labelInitWithText:@"" font:kFontRegular(12) textColor:[UIColor whiteColor]];
|
||
_privilegeNum.hidden = YES;
|
||
NSMutableAttributedString *countAtt = [[NSMutableAttributedString alloc]initWithString:@"今日剩余赠送次数:0次" attributes:@{NSFontAttributeName:kFontRegular(12),NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||
[countAtt addAttributes:@{NSFontAttributeName:kFontMedium(12),NSForegroundColorAttributeName:UIColorFromRGB(0xFFDA24)} range:[countAtt.string rangeOfString:@"0"]];
|
||
_privilegeNum.attributedText = countAtt;
|
||
}
|
||
return _privilegeNum;
|
||
}
|
||
@end
|