提交
This commit is contained in:
@@ -16,7 +16,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
@interface QXMineServiceCell : UITableViewCell
|
||||
@property (nonatomic,weak)id<QXMineServiceCellDelegate>delegate;
|
||||
-(void)cellReload;
|
||||
+(instancetype)cellWithTableView:(UITableView *)tableView;
|
||||
@end
|
||||
|
||||
@interface QXMineServiceSubCell : UICollectionViewCell
|
||||
@property (nonatomic,strong)UIImageView *imageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
//
|
||||
|
||||
#import "QXMineServiceCell.h"
|
||||
@interface QXMineServiceCell()
|
||||
@class QXMineServiceSubCell;
|
||||
@interface QXMineServiceCell()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)NSArray *serviceArray;
|
||||
@property (nonatomic,strong)NSArray *serviceImageArray;
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)NSMutableArray *serviceArray;
|
||||
@property (nonatomic,strong)NSMutableArray *serviceImageArray;
|
||||
@end
|
||||
|
||||
@implementation QXMineServiceCell
|
||||
@@ -51,74 +53,107 @@
|
||||
make.right.mas_equalTo(-12);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
|
||||
NSInteger maxCount = 4;
|
||||
CGFloat btnWith = (SCREEN_WIDTH-32)/maxCount;
|
||||
CGFloat btnWith = (int)(SCREEN_WIDTH-32-1)/maxCount;
|
||||
CGFloat btnHeight = 44;
|
||||
for (int i = 0; i < self.serviceArray.count; i++) {
|
||||
NSInteger col = i / maxCount;
|
||||
NSInteger line = i % maxCount;
|
||||
UIButton *btn = [[UIButton alloc] init];
|
||||
[self.bgView addSubview:btn];
|
||||
[btn setTitle:self.serviceArray[i] forState:(UIControlStateNormal)];
|
||||
[btn setTitleColor:[UIColor clearColor] forState:(UIControlStateNormal)];
|
||||
[btn addTarget:self action:@selector(serviceClick:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(line*btnWith);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(13+col*(btnHeight+13));
|
||||
make.height.mas_equalTo(btnHeight);
|
||||
make.width.mas_equalTo(btnWith);
|
||||
}];
|
||||
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:self.serviceImageArray[i]]];
|
||||
[self.bgView addSubview:imageView];
|
||||
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.centerX.equalTo(btn);
|
||||
make.height.width.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textColor = QXConfig.textColor;
|
||||
titleLabel.text = self.serviceArray[i];
|
||||
titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.bgView addSubview:titleLabel];
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(imageView.mas_bottom).offset(3);
|
||||
make.centerX.equalTo(btn);
|
||||
make.height.mas_equalTo(17);
|
||||
}];
|
||||
|
||||
}
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake(btnWith, btnHeight);
|
||||
layout.minimumLineSpacing = 10;
|
||||
layout.minimumInteritemSpacing = 0;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
[self.collectionView registerClass:[QXMineServiceSubCell class] forCellWithReuseIdentifier:@"QXMineServiceSubCell"];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
self.collectionView.backgroundColor = UIColor.clearColor;
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.bgView);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(22);
|
||||
make.height.mas_equalTo(btnHeight*2+10);
|
||||
// make.right.mas_equalTo(-12);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
|
||||
// for (int i = 0; i < self.serviceArray.count; i++) {
|
||||
// NSInteger col = i / maxCount;
|
||||
// NSInteger line = i % maxCount;
|
||||
// UIButton *btn = [[UIButton alloc] init];
|
||||
// [self.bgView addSubview:btn];
|
||||
// [btn setTitle:self.serviceArray[i] forState:(UIControlStateNormal)];
|
||||
// [btn setTitleColor:[UIColor clearColor] forState:(UIControlStateNormal)];
|
||||
// [btn addTarget:self action:@selector(serviceClick:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
// [btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(line*btnWith);
|
||||
// make.top.equalTo(self.titleLabel.mas_bottom).offset(13+col*(btnHeight+13));
|
||||
// make.height.mas_equalTo(btnHeight);
|
||||
// make.width.mas_equalTo(btnWith);
|
||||
// }];
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
||||
-(void)serviceClick:(UIButton*)sender{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickServiceWithBtn:title:)]) {
|
||||
[self.delegate didClickServiceWithBtn:sender title:sender.titleLabel.text];
|
||||
}
|
||||
}
|
||||
-(NSArray *)serviceArray{
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.serviceArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXMineServiceSubCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXMineServiceSubCell" forIndexPath:indexPath];
|
||||
cell.imageView.image = [UIImage imageNamed:self.serviceImageArray[indexPath.row]];
|
||||
cell.titleLabel.text = self.serviceArray[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickServiceWithBtn:title:)]) {
|
||||
[self.delegate didClickServiceWithBtn:nil title:self.serviceArray[indexPath.row]];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)cellReload{
|
||||
if (QXGlobal.shareGlobal.isOpenRecharge){
|
||||
if ([self.serviceArray containsObject:QXText(@"每日任务")]) {
|
||||
return;
|
||||
}
|
||||
[self.serviceArray addObject:QXText(@"每日任务")];
|
||||
[self.serviceImageArray addObject:@"service_task"];
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
}
|
||||
-(NSMutableArray *)serviceArray{
|
||||
if (!_serviceArray) {
|
||||
_serviceArray = @[
|
||||
_serviceArray = [NSMutableArray arrayWithArray:@[
|
||||
QXText(@"钱包"),
|
||||
QXText(@"段位"),
|
||||
QXText(@"公会中心"),
|
||||
QXText(@"个性装扮"),
|
||||
QXText(@"道具商城"),
|
||||
QXText(@"我的背包"),
|
||||
QXText(@"每日任务"),
|
||||
];
|
||||
]];
|
||||
}
|
||||
return _serviceArray;
|
||||
}
|
||||
-(NSArray *)serviceImageArray{
|
||||
-(NSMutableArray *)serviceImageArray{
|
||||
if (!_serviceImageArray) {
|
||||
_serviceImageArray = @[
|
||||
_serviceImageArray = [NSMutableArray arrayWithArray:@[
|
||||
@"service_wallet",
|
||||
@"service_level",
|
||||
@"service_guild",
|
||||
@"service_dress",
|
||||
@"service_shop",
|
||||
@"service_bag",
|
||||
@"service_task",
|
||||
];
|
||||
]];
|
||||
}
|
||||
|
||||
return _serviceImageArray;
|
||||
@@ -135,3 +170,37 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXMineServiceSubCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
UIImageView *imageView = [[UIImageView alloc] init];
|
||||
[self.contentView addSubview:imageView];
|
||||
self.imageView = imageView;
|
||||
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.centerX.equalTo(self.contentView);
|
||||
make.height.width.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textColor = QXConfig.textColor;
|
||||
titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:titleLabel];
|
||||
self.titleLabel = titleLabel;
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(imageView.mas_bottom).offset(3);
|
||||
make.centerX.equalTo(self.contentView);
|
||||
make.height.mas_equalTo(17);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
self.rightBgView = [[QXWalletHomeTopSubview alloc] init];
|
||||
self.rightBgView.isCorn = NO;
|
||||
self.rightBgView.delegate = self;
|
||||
self.rightBgView.btn.hidden = !QXGlobal.shareGlobal.isOpenRecharge;
|
||||
[self addSubview:self.rightBgView];
|
||||
[self.rightBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(-16);
|
||||
|
||||
Reference in New Issue
Block a user