Commit 2e03faa8d8d41415ab9d6cd867609595517617ba
1 parent
7d9b3873
no message
Showing
8 changed files
with
267 additions
and
189 deletions
CNLiveMineModule/Classes/Controller/CNLiveMineController.m
| @@ -44,6 +44,8 @@ static const CGFloat timeValue = 1.5; | @@ -44,6 +44,8 @@ static const CGFloat timeValue = 1.5; | ||
| 44 | @"name":@"我的订单", | 44 | @"name":@"我的订单", |
| 45 | @"style":@"1", | 45 | @"style":@"1", |
| 46 | @"margin":@"10", | 46 | @"margin":@"10", |
| 47 | + @"titleHeight":@"50", | ||
| 48 | + @"itemHeight":@"60", | ||
| 47 | @"buttons":@[@{ | 49 | @"buttons":@[@{ |
| 48 | @"title":@"订单", | 50 | @"title":@"订单", |
| 49 | @"image":@"mine_order" | 51 | @"image":@"mine_order" |
| @@ -67,6 +69,8 @@ static const CGFloat timeValue = 1.5; | @@ -67,6 +69,8 @@ static const CGFloat timeValue = 1.5; | ||
| 67 | @"name":@"常用工具", | 69 | @"name":@"常用工具", |
| 68 | @"style":@"2", | 70 | @"style":@"2", |
| 69 | @"margin":@"10", | 71 | @"margin":@"10", |
| 72 | + @"titleHeight":@"50", | ||
| 73 | + @"itemHeight":@"60", | ||
| 70 | @"buttons":@[@{ | 74 | @"buttons":@[@{ |
| 71 | @"title":@"收货地址", | 75 | @"title":@"收货地址", |
| 72 | @"image":@"mine_address" | 76 | @"image":@"mine_address" |
| @@ -103,6 +107,8 @@ static const CGFloat timeValue = 1.5; | @@ -103,6 +107,8 @@ static const CGFloat timeValue = 1.5; | ||
| 103 | @"pic":@"mine_buy_commodity", | 107 | @"pic":@"mine_buy_commodity", |
| 104 | @"style":@"3", | 108 | @"style":@"3", |
| 105 | @"margin":@"10", | 109 | @"margin":@"10", |
| 110 | + @"titleHeight":@"50", | ||
| 111 | + @"itemHeight":@"80", | ||
| 106 | @"buttons":@[@{ | 112 | @"buttons":@[@{ |
| 107 | @"title":@"电子票", | 113 | @"title":@"电子票", |
| 108 | @"image":@"mine_e-ticket" | 114 | @"image":@"mine_e-ticket" |
| @@ -115,6 +121,8 @@ static const CGFloat timeValue = 1.5; | @@ -115,6 +121,8 @@ static const CGFloat timeValue = 1.5; | ||
| 115 | @"pic":@"mine_china_sport", | 121 | @"pic":@"mine_china_sport", |
| 116 | @"style":@"4", | 122 | @"style":@"4", |
| 117 | @"margin":@"10", | 123 | @"margin":@"10", |
| 124 | + @"titleHeight":@"50", | ||
| 125 | + @"itemHeight":@"60", | ||
| 118 | @"buttons":@[@{ | 126 | @"buttons":@[@{ |
| 119 | @"title":@"我的活动", | 127 | @"title":@"我的活动", |
| 120 | @"image":@"mine_activity" | 128 | @"image":@"mine_activity" |
| @@ -146,6 +154,7 @@ static const CGFloat timeValue = 1.5; | @@ -146,6 +154,7 @@ static const CGFloat timeValue = 1.5; | ||
| 146 | if(self.soccerBtn){ | 154 | if(self.soccerBtn){ |
| 147 | self.soccerBtn.frame = CGRectMake(SCREEN_WIDTH-67-10, SCREEN_HEIGHT-71-10-TabBarHeight, 67, 71); | 155 | self.soccerBtn.frame = CGRectMake(SCREEN_WIDTH-67-10, SCREEN_HEIGHT-71-10-TabBarHeight, 67, 71); |
| 148 | } | 156 | } |
| 157 | + [self.tableView reloadData]; | ||
| 149 | } | 158 | } |
| 150 | 159 | ||
| 151 | - (void)viewDidLoad { | 160 | - (void)viewDidLoad { |
| @@ -161,11 +170,6 @@ static const CGFloat timeValue = 1.5; | @@ -161,11 +170,6 @@ static const CGFloat timeValue = 1.5; | ||
| 161 | [self loadData]; | 170 | [self loadData]; |
| 162 | } | 171 | } |
| 163 | 172 | ||
| 164 | -- (void)dealloc { | ||
| 165 | - | ||
| 166 | - | ||
| 167 | -} | ||
| 168 | - | ||
| 169 | - (void)createSubViews { | 173 | - (void)createSubViews { |
| 170 | [self.view addSubview:self.tableView]; | 174 | [self.view addSubview:self.tableView]; |
| 171 | CNLiveMineHeaderView *headerView = [[CNLiveMineHeaderView alloc]initWithFrame:CGRectMake(0, -kHEIGHT, SCREEN_WIDTH, kHEIGHT)]; | 175 | CNLiveMineHeaderView *headerView = [[CNLiveMineHeaderView alloc]initWithFrame:CGRectMake(0, -kHEIGHT, SCREEN_WIDTH, kHEIGHT)]; |
| @@ -199,6 +203,7 @@ static const CGFloat timeValue = 1.5; | @@ -199,6 +203,7 @@ static const CGFloat timeValue = 1.5; | ||
| 199 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | 203 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 200 | 204 | ||
| 201 | } | 205 | } |
| 206 | + | ||
| 202 | #pragma mark - CNLiveMineHeaderViewDelegate | 207 | #pragma mark - CNLiveMineHeaderViewDelegate |
| 203 | - (void)headerView:(CNLiveMineHeaderView *)headerView pushToController:(CNLiveMineHeaderViewType)type{ | 208 | - (void)headerView:(CNLiveMineHeaderView *)headerView pushToController:(CNLiveMineHeaderViewType)type{ |
| 204 | switch (type) { | 209 | switch (type) { |
| @@ -253,66 +258,65 @@ static const CGFloat timeValue = 1.5; | @@ -253,66 +258,65 @@ static const CGFloat timeValue = 1.5; | ||
| 253 | } | 258 | } |
| 254 | 259 | ||
| 255 | #pragma mark - CNLiveMineCellDelegate | 260 | #pragma mark - CNLiveMineCellDelegate |
| 256 | -- (void)cell:(CNLiveMineCell *)cell clickedButtonWithType:(CNLiveMineCellType)type tag:(NSInteger)tag{ | ||
| 257 | - switch (type) { | 261 | +- (void)cell:(CNLiveMineCell *)cell didSelectItemAtItem:(NSInteger)item{ |
| 262 | + switch (cell.model.type) { | ||
| 258 | case CNLiveMineCellTypeOrder: | 263 | case CNLiveMineCellTypeOrder: |
| 259 | { | 264 | { |
| 260 | - if(tag-10000 == 4){ | 265 | + if(item == 4){ |
| 261 | //售后 | 266 | //售后 |
| 262 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; | 267 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; |
| 263 | [service pushToRefundViewController:0]; | 268 | [service pushToRefundViewController:0]; |
| 264 | 269 | ||
| 265 | }else{ | 270 | }else{ |
| 266 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; | 271 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; |
| 267 | - [service pushToOrderViewController:tag-10000]; | 272 | + [service pushToOrderViewController:item]; |
| 268 | } | 273 | } |
| 269 | } | 274 | } |
| 270 | break; | 275 | break; |
| 271 | case CNLiveMineCellTypeTool: | 276 | case CNLiveMineCellTypeTool: |
| 272 | { | 277 | { |
| 273 | - if(tag == 10000){ | 278 | + if(item == 0){ |
| 274 | // 收货地址 | 279 | // 收货地址 |
| 275 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; | 280 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; |
| 276 | [service pushToAddressViewController]; | 281 | [service pushToAddressViewController]; |
| 277 | } | 282 | } |
| 278 | - else if(tag == 10001){ | 283 | + else if(item == 1){ |
| 279 | // 余额 | 284 | // 余额 |
| 280 | // XWBalanceController *vc = [[XWBalanceController alloc]init]; | 285 | // XWBalanceController *vc = [[XWBalanceController alloc]init]; |
| 281 | // [self.navigationController pushViewController:vc animated:YES]; | 286 | // [self.navigationController pushViewController:vc animated:YES]; |
| 282 | } | 287 | } |
| 283 | - else if(tag == 10002){ | 288 | + else if(item == 2){ |
| 284 | // 收藏 | 289 | // 收藏 |
| 285 | id<CNLiveCollectionServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveCollectionServiceProtocol)]; | 290 | id<CNLiveCollectionServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveCollectionServiceProtocol)]; |
| 286 | [service pushToCollectionViewController]; | 291 | [service pushToCollectionViewController]; |
| 287 | } | 292 | } |
| 288 | - else if(tag == 10003){ | 293 | + else if(item == 3){ |
| 289 | // 发布记录 | 294 | // 发布记录 |
| 290 | // XWOrdersController *vc = [[XWOrdersController alloc]init]; | 295 | // XWOrdersController *vc = [[XWOrdersController alloc]init]; |
| 291 | // [self.navigationController pushViewController:vc animated:YES]; | 296 | // [self.navigationController pushViewController:vc animated:YES]; |
| 292 | } | 297 | } |
| 293 | - else if(tag == 10004){ | 298 | + else if(item == 4){ |
| 294 | // 邀请好友 | 299 | // 邀请好友 |
| 295 | // XWOrdersController *vc = [[XWOrdersController alloc]init]; | 300 | // XWOrdersController *vc = [[XWOrdersController alloc]init]; |
| 296 | // [self.navigationController pushViewController:vc animated:YES]; | 301 | // [self.navigationController pushViewController:vc animated:YES]; |
| 297 | } | 302 | } |
| 298 | - else if(tag == 10005){ | 303 | + else if(item == 5){ |
| 299 | // 设置 | 304 | // 设置 |
| 300 | id<CNLiveSettingServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveSettingServiceProtocol)]; | 305 | id<CNLiveSettingServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveSettingServiceProtocol)]; |
| 301 | [service pushToSettingViewController]; | 306 | [service pushToSettingViewController]; |
| 302 | } | 307 | } |
| 303 | - else if(tag == 10006){ | 308 | + else if(item == 6){ |
| 304 | // 小家音响 | 309 | // 小家音响 |
| 305 | 310 | ||
| 306 | } | 311 | } |
| 307 | - else if(tag == 10007){ | 312 | + else if(item == 7){ |
| 308 | // 我的礼盒 | 313 | // 我的礼盒 |
| 309 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; | 314 | id<CNLiveOrderServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveOrderServiceProtocol)]; |
| 310 | [service pushToGiftBoxViewController]; | 315 | [service pushToGiftBoxViewController]; |
| 311 | } | 316 | } |
| 312 | - else if(tag == 10008){ | 317 | + else if(item == 8){ |
| 313 | // 路径工具 | 318 | // 路径工具 |
| 314 | -// XWOrdersController *vc = [[XWOrdersController alloc]init]; | ||
| 315 | -// [self.navigationController pushViewController:vc animated:YES]; | 319 | + |
| 316 | } | 320 | } |
| 317 | 321 | ||
| 318 | } | 322 | } |
| @@ -324,11 +328,11 @@ static const CGFloat timeValue = 1.5; | @@ -324,11 +328,11 @@ static const CGFloat timeValue = 1.5; | ||
| 324 | break; | 328 | break; |
| 325 | case CNLiveMineCellTypeSports: | 329 | case CNLiveMineCellTypeSports: |
| 326 | { | 330 | { |
| 327 | - if(tag == 10000){ | 331 | + if(item == 0){ |
| 328 | // 我的活动 | 332 | // 我的活动 |
| 329 | 333 | ||
| 330 | } | 334 | } |
| 331 | - else if(tag == 10001){ | 335 | + else if(item == 1){ |
| 332 | // 我的记录 | 336 | // 我的记录 |
| 333 | 337 | ||
| 334 | } | 338 | } |
CNLiveMineModule/Classes/Model/CNLiveMineModel.h
| @@ -34,6 +34,10 @@ typedef NS_ENUM(NSInteger, CNLiveMineCellType) { | @@ -34,6 +34,10 @@ typedef NS_ENUM(NSInteger, CNLiveMineCellType) { | ||
| 34 | @property (nonatomic, assign) CNLiveMineCellType type; | 34 | @property (nonatomic, assign) CNLiveMineCellType type; |
| 35 | 35 | ||
| 36 | @property (nonatomic, assign) CGFloat height; | 36 | @property (nonatomic, assign) CGFloat height; |
| 37 | +// title的高度 | ||
| 38 | +@property (nonatomic, assign) CGFloat titleHeight; | ||
| 39 | +// UICollectionView一个item的高度 | ||
| 40 | +@property (nonatomic, assign) CGFloat itemHeight; | ||
| 37 | @property (nonatomic, assign) CGFloat margin; | 41 | @property (nonatomic, assign) CGFloat margin; |
| 38 | 42 | ||
| 39 | // 是否显示路径工具 | 43 | // 是否显示路径工具 |
CNLiveMineModule/Classes/Model/CNLiveMineModel.m
| @@ -46,27 +46,24 @@ static const NSInteger margin = 10; | @@ -46,27 +46,24 @@ static const NSInteger margin = 10; | ||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | - (CGFloat)height{ | 48 | - (CGFloat)height{ |
| 49 | - CGFloat titleHeight = 50; | ||
| 50 | - CGFloat btnHeight = 60; | ||
| 51 | - | ||
| 52 | //订单 | 49 | //订单 |
| 53 | if(self.type == CNLiveMineCellTypeOrder){ | 50 | if(self.type == CNLiveMineCellTypeOrder){ |
| 54 | - return 2*margin+titleHeight+btnHeight+margin; | 51 | + return 2*margin+self.titleHeight+self.itemHeight+margin; |
| 55 | } | 52 | } |
| 56 | //工具 | 53 | //工具 |
| 57 | else if(self.type == CNLiveMineCellTypeTool){ | 54 | else if(self.type == CNLiveMineCellTypeTool){ |
| 58 | - return 2*margin+titleHeight+ceilf(self.buttons.count/4.0)*(btnHeight+margin); | 55 | + return 2*margin+self.titleHeight+ceilf(self.buttons.count/4.0)*(self.itemHeight+margin); |
| 59 | 56 | ||
| 60 | } | 57 | } |
| 61 | //商品 | 58 | //商品 |
| 62 | else if(self.type == CNLiveMineCellTypeGoods){ | 59 | else if(self.type == CNLiveMineCellTypeGoods){ |
| 63 | // 电票的高度 80 | 60 | // 电票的高度 80 |
| 64 | - return 2*margin+titleHeight+80+margin; | 61 | + return 2*margin+self.titleHeight+self.itemHeight+margin; |
| 65 | 62 | ||
| 66 | } | 63 | } |
| 67 | //大众体育 | 64 | //大众体育 |
| 68 | else if(self.type == CNLiveMineCellTypeSports){ | 65 | else if(self.type == CNLiveMineCellTypeSports){ |
| 69 | - return 2*margin+titleHeight+ceilf(self.buttons.count/4.0)*(btnHeight+margin); | 66 | + return 2*margin+self.titleHeight+ceilf(self.buttons.count/4.0)*(self.itemHeight+margin); |
| 70 | 67 | ||
| 71 | } | 68 | } |
| 72 | return 0.0000001f; | 69 | return 0.0000001f; |
CNLiveMineModule/Classes/View/CNLiveMineButtonCell.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveMineButtonCell.h | ||
| 3 | +// CNLiveMineModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <UIKit/UIKit.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | +@class CNLiveMineButtonModel; | ||
| 13 | + | ||
| 14 | +static NSString * const kCNLiveMineButtonCell = @"CNLiveMineButtonCell"; | ||
| 15 | + | ||
| 16 | +@interface CNLiveMineButtonCell : UICollectionViewCell | ||
| 17 | +@property (nonatomic, strong) CNLiveMineButtonModel *model; | ||
| 18 | + | ||
| 19 | +@end | ||
| 20 | + | ||
| 21 | +NS_ASSUME_NONNULL_END |
CNLiveMineModule/Classes/View/CNLiveMineButtonCell.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveMineButtonCell.m | ||
| 3 | +// CNLiveMineModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveMineButtonCell.h" | ||
| 10 | +#import <Masonry/Masonry.h> | ||
| 11 | +#import "QMUIKit.h" | ||
| 12 | +#import "CNLiveCategory.h" | ||
| 13 | +#import "CNLiveBaseKit.h" | ||
| 14 | +#import "CNLiveMineModel.h" | ||
| 15 | + | ||
| 16 | +@interface CNLiveMineButtonCell() | ||
| 17 | +@property (nonatomic, strong) UIImageView *image; | ||
| 18 | +@property (nonatomic, strong) UILabel *title; | ||
| 19 | + | ||
| 20 | +@end | ||
| 21 | + | ||
| 22 | +@implementation CNLiveMineButtonCell | ||
| 23 | +#pragma mark - 生命周期 | ||
| 24 | +- (id)initWithFrame:(CGRect)frame { | ||
| 25 | + self = [super initWithFrame:frame]; | ||
| 26 | + if (self) { | ||
| 27 | + self.contentView.backgroundColor = [UIColor whiteColor]; | ||
| 28 | + [self.contentView addSubview:self.image]; | ||
| 29 | + [self.contentView addSubview:self.title]; | ||
| 30 | + } | ||
| 31 | + return self; | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +- (void)layoutSubviews{ | ||
| 35 | + [super layoutSubviews]; | ||
| 36 | + [_image mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 37 | + make.left.equalTo(self.contentView.mas_left); | ||
| 38 | + make.right.equalTo(self.contentView.mas_right); | ||
| 39 | + make.top.equalTo(self.contentView.mas_top); | ||
| 40 | + make.height.offset(self.frame.size.height*2/3.0); | ||
| 41 | + | ||
| 42 | + }]; | ||
| 43 | + [_title mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 44 | + make.top.equalTo(self.image.mas_bottom); | ||
| 45 | + make.left.equalTo(self.image.mas_left); | ||
| 46 | + make.right.equalTo(self.image.mas_right); | ||
| 47 | + make.bottom.equalTo(self.contentView.mas_bottom); | ||
| 48 | + | ||
| 49 | + }]; | ||
| 50 | + | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +#pragma mark - 数据 | ||
| 54 | +- (void)setModel:(CNLiveMineButtonModel *)model{ | ||
| 55 | + UIImage *xw_image = [self getImageWithImageName:model.image bundleName:@"CNLiveMineModule" targetClass:[self class]]; | ||
| 56 | + _image.image = xw_image; | ||
| 57 | + _title.text = model.title; | ||
| 58 | + _title.font = UIFontCNMake(12.0); | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +- (void)awakeFromNib { | ||
| 62 | + [super awakeFromNib]; | ||
| 63 | + // Initialization code | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +#pragma mark - 懒加载 | ||
| 67 | +- (UIImageView *)image{ | ||
| 68 | + if (!_image) { | ||
| 69 | + _image = [[UIImageView alloc] init]; | ||
| 70 | + _image.contentMode = UIViewContentModeCenter; | ||
| 71 | + } | ||
| 72 | + return _image; | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +- (UILabel *)title { | ||
| 76 | + if (!_title) { | ||
| 77 | + _title = [[UILabel alloc] init]; | ||
| 78 | + _title.userInteractionEnabled = YES; | ||
| 79 | + _title.numberOfLines = 1; | ||
| 80 | + _title.lineBreakMode = NSLineBreakByTruncatingTail; | ||
| 81 | + _title.textColor = [UIColor blackColor]; | ||
| 82 | + _title.textAlignment = NSTextAlignmentCenter; | ||
| 83 | + _title.font = UIFontCNMake(12.0); | ||
| 84 | + } | ||
| 85 | + return _title; | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +@end |
CNLiveMineModule/Classes/View/CNLiveMineCell.h
| @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN | @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN | ||
| 15 | static NSString * const kCNLiveMineCell = @"CNLiveMineCell"; | 15 | static NSString * const kCNLiveMineCell = @"CNLiveMineCell"; |
| 16 | @protocol CNLiveMineCellDelegate <NSObject> | 16 | @protocol CNLiveMineCellDelegate <NSObject> |
| 17 | @optional | 17 | @optional |
| 18 | -- (void)cell:(CNLiveMineCell *)cell clickedButtonWithType:(CNLiveMineCellType)type tag:(NSInteger)tag; | 18 | +- (void)cell:(CNLiveMineCell *)cell didSelectItemAtItem:(NSInteger)item; |
| 19 | 19 | ||
| 20 | @end | 20 | @end |
| 21 | 21 |
CNLiveMineModule/Classes/View/CNLiveMineCell.m
| @@ -11,87 +11,110 @@ | @@ -11,87 +11,110 @@ | ||
| 11 | #import "QMUIKit.h" | 11 | #import "QMUIKit.h" |
| 12 | #import "CNLiveCategory.h" | 12 | #import "CNLiveCategory.h" |
| 13 | #import "CNLiveBaseKit.h" | 13 | #import "CNLiveBaseKit.h" |
| 14 | +#import "CNLiveMineButtonCell.h" | ||
| 14 | 15 | ||
| 15 | -@interface CNLiveMineCell() | 16 | +@interface CNLiveMineCell()<UICollectionViewDelegate, UICollectionViewDataSource> |
| 16 | @property (nonatomic, strong) UIView *bgView; | 17 | @property (nonatomic, strong) UIView *bgView; |
| 17 | @property (nonatomic, strong) UIButton *titleButton; | 18 | @property (nonatomic, strong) UIButton *titleButton; |
| 18 | @property (nonatomic, strong) UIButton *allButton; | 19 | @property (nonatomic, strong) UIButton *allButton; |
| 19 | 20 | ||
| 20 | @property (nonatomic, strong) UIView *line; | 21 | @property (nonatomic, strong) UIView *line; |
| 22 | +@property (nonatomic, strong) NSMutableArray *buttons; | ||
| 23 | + | ||
| 24 | +@property (nonatomic, strong) UICollectionView *collectionView; | ||
| 21 | 25 | ||
| 22 | @end | 26 | @end |
| 23 | 27 | ||
| 24 | @implementation CNLiveMineCell | 28 | @implementation CNLiveMineCell |
| 29 | + | ||
| 25 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ | 30 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ |
| 26 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; | 31 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
| 27 | if (self) { | 32 | if (self) { |
| 28 | self.contentView.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0]; | 33 | self.contentView.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0]; |
| 29 | - [self xw_layoutSubviews]; | 34 | + [self createSubviews]; |
| 30 | } | 35 | } |
| 31 | return self; | 36 | return self; |
| 32 | } | 37 | } |
| 33 | 38 | ||
| 34 | -- (void)xw_layoutSubviews{ | 39 | +- (void)createSubviews{ |
| 35 | [self.contentView addSubview:self.bgView]; | 40 | [self.contentView addSubview:self.bgView]; |
| 36 | [self.contentView addSubview:self.titleButton]; | 41 | [self.contentView addSubview:self.titleButton]; |
| 37 | [self.contentView addSubview:self.allButton]; | 42 | [self.contentView addSubview:self.allButton]; |
| 38 | [self.contentView addSubview:self.line]; | 43 | [self.contentView addSubview:self.line]; |
| 39 | - | 44 | + [self.contentView addSubview:self.collectionView]; |
| 45 | + | ||
| 40 | } | 46 | } |
| 41 | 47 | ||
| 42 | - (void)setModel:(CNLiveMineModel *)model{ | 48 | - (void)setModel:(CNLiveMineModel *)model{ |
| 43 | - if(_model == model){ | ||
| 44 | - return; | ||
| 45 | - } | ||
| 46 | _model = model; | 49 | _model = model; |
| 50 | + | ||
| 47 | [_titleButton setTitle:model.name forState:UIControlStateNormal]; | 51 | [_titleButton setTitle:model.name forState:UIControlStateNormal]; |
| 52 | + _titleButton.titleLabel.font = UIFontBoldCNMake(15.0); | ||
| 53 | + | ||
| 48 | UIImage *xw_image = [self getImageWithImageName:model.pic bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; | 54 | UIImage *xw_image = [self getImageWithImageName:model.pic bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; |
| 49 | [_titleButton setImage:xw_image forState:UIControlStateNormal]; | 55 | [_titleButton setImage:xw_image forState:UIControlStateNormal]; |
| 56 | + | ||
| 50 | _allButton.hidden = YES; | 57 | _allButton.hidden = YES; |
| 51 | - | 58 | + _allButton.titleLabel.font = UIFontCNMake(12.0); |
| 59 | + | ||
| 60 | + [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 61 | + make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); | ||
| 62 | + make.right.equalTo(self.contentView.mas_right).with.offset(-self.model.margin); | ||
| 63 | + make.top.equalTo(self.contentView.mas_top).with.offset(0); | ||
| 64 | + make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-self.model.margin); | ||
| 65 | + | ||
| 66 | + }]; | ||
| 52 | switch (model.type) { | 67 | switch (model.type) { |
| 53 | case CNLiveMineCellTypeOrder: | 68 | case CNLiveMineCellTypeOrder: |
| 54 | { | 69 | { |
| 55 | [self order_layoutSubviews]; | 70 | [self order_layoutSubviews]; |
| 56 | } | 71 | } |
| 57 | break; | 72 | break; |
| 58 | - | 73 | + |
| 59 | case CNLiveMineCellTypeTool: | 74 | case CNLiveMineCellTypeTool: |
| 60 | { | 75 | { |
| 61 | [self tool_layoutSubviews]; | 76 | [self tool_layoutSubviews]; |
| 62 | } | 77 | } |
| 63 | break; | 78 | break; |
| 64 | - | 79 | + |
| 65 | case CNLiveMineCellTypeGoods: | 80 | case CNLiveMineCellTypeGoods: |
| 66 | { | 81 | { |
| 67 | [self goods_layoutSubviews]; | 82 | [self goods_layoutSubviews]; |
| 68 | } | 83 | } |
| 69 | break; | 84 | break; |
| 70 | - | 85 | + |
| 71 | case CNLiveMineCellTypeSports: | 86 | case CNLiveMineCellTypeSports: |
| 72 | { | 87 | { |
| 73 | [self sports_layoutSubviews]; | 88 | [self sports_layoutSubviews]; |
| 74 | } | 89 | } |
| 75 | break; | 90 | break; |
| 76 | } | 91 | } |
| 92 | + [_line mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 93 | + make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); | ||
| 94 | + make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | ||
| 95 | + make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 96 | + make.height.with.offset(0.5); | ||
| 97 | + | ||
| 98 | + }]; | ||
| 99 | + [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 100 | + make.top.equalTo(self.line.mas_bottom); | ||
| 101 | + make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | ||
| 102 | + make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 103 | + make.bottom.equalTo(self.bgView.mas_bottom); | ||
| 104 | + }]; | ||
| 105 | + [_collectionView reloadData]; | ||
| 106 | + | ||
| 77 | } | 107 | } |
| 78 | 108 | ||
| 79 | - (void)order_layoutSubviews{ | 109 | - (void)order_layoutSubviews{ |
| 80 | - [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 81 | - make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); | ||
| 82 | - make.right.equalTo(self.contentView.mas_right).with.offset(-self.model.margin); | ||
| 83 | - make.top.equalTo(self.contentView.mas_top).with.offset(0); | ||
| 84 | - make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-self.model.margin); | ||
| 85 | - | ||
| 86 | - }]; | ||
| 87 | [_titleButton setImage:nil forState:UIControlStateNormal]; | 110 | [_titleButton setImage:nil forState:UIControlStateNormal]; |
| 88 | _titleButton.titleLabel.textAlignment = NSTextAlignmentLeft; | 111 | _titleButton.titleLabel.textAlignment = NSTextAlignmentLeft; |
| 89 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//使图片和文字水平居中显示 | 112 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//使图片和文字水平居中显示 |
| 90 | [_titleButton mas_makeConstraints:^(MASConstraintMaker *make) { | 113 | [_titleButton mas_makeConstraints:^(MASConstraintMaker *make) { |
| 91 | - make.top.equalTo(self.bgView.mas_top).with.offset(0); | 114 | + make.top.equalTo(self.bgView.mas_top); |
| 92 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | 115 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); |
| 93 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | 116 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); |
| 94 | - make.height.with.offset(50); | 117 | + make.height.with.offset(self.model.titleHeight); |
| 95 | 118 | ||
| 96 | }]; | 119 | }]; |
| 97 | 120 | ||
| @@ -99,38 +122,12 @@ | @@ -99,38 +122,12 @@ | ||
| 99 | [_allButton mas_makeConstraints:^(MASConstraintMaker *make) { | 122 | [_allButton mas_makeConstraints:^(MASConstraintMaker *make) { |
| 100 | make.top.equalTo(self.titleButton.mas_top); | 123 | make.top.equalTo(self.titleButton.mas_top); |
| 101 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | 124 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); |
| 102 | - make.height.with.offset(50); | 125 | + make.height.with.offset(self.model.titleHeight); |
| 103 | 126 | ||
| 104 | }]; | 127 | }]; |
| 105 | 128 | ||
| 106 | - [_line mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 107 | - make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); | ||
| 108 | - make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | ||
| 109 | - make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 110 | - make.height.with.offset(0.5); | ||
| 111 | - | ||
| 112 | - }]; | ||
| 113 | - | ||
| 114 | - CGFloat width = SCREEN_WIDTH-2*self.model.margin; | ||
| 115 | - CGFloat btnWidth = width/self.model.buttons.count*1.0; | ||
| 116 | - CGFloat btnHeight = 60; | ||
| 117 | - | ||
| 118 | - for(int i = 0; i < self.model.buttons.count; i++){ | ||
| 119 | - CNLiveMineButtonModel *buttonModel = self.model.buttons[i]; | ||
| 120 | - UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*i, 50+self.model.margin, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000+i]; | ||
| 121 | - [self addSubview:btn]; | ||
| 122 | - | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | } | 129 | } |
| 126 | - (void)tool_layoutSubviews{ | 130 | - (void)tool_layoutSubviews{ |
| 127 | - [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 128 | - make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); | ||
| 129 | - make.right.equalTo(self.contentView.mas_right).with.offset(-self.model.margin); | ||
| 130 | - make.top.equalTo(self.contentView.mas_top).with.offset(0); | ||
| 131 | - make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-self.model.margin); | ||
| 132 | - | ||
| 133 | - }]; | ||
| 134 | [_titleButton setImage:nil forState:UIControlStateNormal]; | 131 | [_titleButton setImage:nil forState:UIControlStateNormal]; |
| 135 | _titleButton.titleLabel.textAlignment = NSTextAlignmentLeft; | 132 | _titleButton.titleLabel.textAlignment = NSTextAlignmentLeft; |
| 136 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//使图片和文字水平居中显示 | 133 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//使图片和文字水平居中显示 |
| @@ -138,115 +135,41 @@ | @@ -138,115 +135,41 @@ | ||
| 138 | make.top.equalTo(self.bgView.mas_top).with.offset(0); | 135 | make.top.equalTo(self.bgView.mas_top).with.offset(0); |
| 139 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | 136 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); |
| 140 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | 137 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); |
| 141 | - make.height.with.offset(50); | ||
| 142 | - | ||
| 143 | - }]; | ||
| 144 | - _allButton.hidden = YES; | ||
| 145 | - | ||
| 146 | - [_line mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 147 | - make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); | ||
| 148 | - make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | ||
| 149 | - make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 150 | - make.height.with.offset(0.5); | 138 | + make.height.with.offset(self.model.titleHeight); |
| 151 | 139 | ||
| 152 | }]; | 140 | }]; |
| 153 | - | ||
| 154 | - CGFloat width = SCREEN_WIDTH-2*self.model.margin; | ||
| 155 | - | ||
| 156 | - CGFloat btnWidth = width/4.0; | ||
| 157 | - CGFloat btnHeight = 60; | ||
| 158 | 141 | ||
| 159 | - for(int i = 0; i < self.model.buttons.count; i++){ | ||
| 160 | - CNLiveMineButtonModel *buttonModel = self.model.buttons[i]; | ||
| 161 | - NSInteger row = i % 4; | ||
| 162 | - NSInteger col = floorf(i / 4.0); | ||
| 163 | - UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*row, (col*(btnHeight+self.model.margin))+50+self.model.margin, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000+i]; | ||
| 164 | - [self addSubview:btn]; | ||
| 165 | - | ||
| 166 | - } | ||
| 167 | } | 142 | } |
| 168 | - (void)goods_layoutSubviews{ | 143 | - (void)goods_layoutSubviews{ |
| 169 | [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin, 0, 0)]; | 144 | [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin, 0, 0)]; |
| 170 | [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin, 0, 0)]; | 145 | [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin, 0, 0)]; |
| 171 | 146 | ||
| 172 | - [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 173 | - make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); | ||
| 174 | - make.right.equalTo(self.contentView.mas_right).with.offset(-self.model.margin); | ||
| 175 | - make.top.equalTo(self.contentView.mas_top).with.offset(0); | ||
| 176 | - make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-self.model.margin); | ||
| 177 | - | ||
| 178 | - }]; | ||
| 179 | _titleButton.titleLabel.textAlignment = NSTextAlignmentCenter; | 147 | _titleButton.titleLabel.textAlignment = NSTextAlignmentCenter; |
| 180 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示 | 148 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示 |
| 181 | [_titleButton mas_makeConstraints:^(MASConstraintMaker *make) { | 149 | [_titleButton mas_makeConstraints:^(MASConstraintMaker *make) { |
| 182 | make.top.equalTo(self.bgView.mas_top).with.offset(0); | 150 | make.top.equalTo(self.bgView.mas_top).with.offset(0); |
| 183 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | 151 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); |
| 184 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | 152 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); |
| 185 | - make.height.with.offset(50); | 153 | + make.height.with.offset(self.model.titleHeight); |
| 186 | 154 | ||
| 187 | }]; | 155 | }]; |
| 188 | - _allButton.hidden = YES; | ||
| 189 | - | ||
| 190 | - [_line mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 191 | - make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); | ||
| 192 | - make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | ||
| 193 | - make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 194 | - make.height.with.offset(0.5); | ||
| 195 | - | ||
| 196 | - }]; | ||
| 197 | - CGFloat width = SCREEN_WIDTH-2*self.model.margin; | ||
| 198 | - CGFloat btnWidth = width/4.0; | ||
| 199 | - CGFloat btnHeight = 80; | ||
| 200 | - | ||
| 201 | - // 电子票 | ||
| 202 | - CNLiveMineButtonModel *buttonModel = self.model.buttons[0]; | ||
| 203 | - UIButton *btn = [self createButtonWithFrame:CGRectMake((width-btnWidth)/2.0, self.model.margin+50, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000]; | ||
| 204 | - [self addSubview:btn]; | ||
| 205 | 156 | ||
| 206 | } | 157 | } |
| 158 | + | ||
| 207 | - (void)sports_layoutSubviews{ | 159 | - (void)sports_layoutSubviews{ |
| 208 | [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin, 0, 0)]; | 160 | [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin, 0, 0)]; |
| 209 | [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin, 0, 0)]; | 161 | [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin, 0, 0)]; |
| 210 | 162 | ||
| 211 | - [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 212 | - make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); | ||
| 213 | - make.right.equalTo(self.contentView.mas_right).with.offset(-self.model.margin); | ||
| 214 | - make.top.equalTo(self.contentView.mas_top).with.offset(0); | ||
| 215 | - make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-self.model.margin); | ||
| 216 | - | ||
| 217 | - }]; | ||
| 218 | _titleButton.titleLabel.textAlignment = NSTextAlignmentCenter; | 163 | _titleButton.titleLabel.textAlignment = NSTextAlignmentCenter; |
| 219 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示 | 164 | _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示 |
| 220 | [_titleButton mas_makeConstraints:^(MASConstraintMaker *make) { | 165 | [_titleButton mas_makeConstraints:^(MASConstraintMaker *make) { |
| 221 | make.top.equalTo(self.bgView.mas_top).with.offset(0); | 166 | make.top.equalTo(self.bgView.mas_top).with.offset(0); |
| 222 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | 167 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); |
| 223 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | 168 | make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); |
| 224 | - make.height.with.offset(50); | ||
| 225 | - | ||
| 226 | - }]; | ||
| 227 | - _allButton.hidden = YES; | ||
| 228 | - | ||
| 229 | - [_line mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 230 | - make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); | ||
| 231 | - make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | ||
| 232 | - make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 233 | - make.height.with.offset(0.5); | 169 | + make.height.with.offset(self.model.titleHeight); |
| 234 | 170 | ||
| 235 | }]; | 171 | }]; |
| 236 | 172 | ||
| 237 | - CGFloat width = SCREEN_WIDTH-2*self.model.margin; | ||
| 238 | - | ||
| 239 | - CGFloat btnWidth = width/4.0; | ||
| 240 | - CGFloat btnHeight = 60; | ||
| 241 | - | ||
| 242 | - for(int i = 0; i < self.model.buttons.count; i++){ | ||
| 243 | - CNLiveMineButtonModel *buttonModel = self.model.buttons[i]; | ||
| 244 | - NSInteger row = i % 4; | ||
| 245 | - NSInteger col = floorf(i / 4.0); | ||
| 246 | - UIButton *btn = [self createButtonWithFrame:CGRectMake(self.model.margin+btnWidth*row, (col*(btnHeight+self.model.margin))+50+self.model.margin, btnWidth, btnHeight) title:buttonModel.title image:buttonModel.image tag:10000+i]; | ||
| 247 | - [self addSubview:btn]; | ||
| 248 | - | ||
| 249 | - } | ||
| 250 | } | 173 | } |
| 251 | 174 | ||
| 252 | - (void)awakeFromNib { | 175 | - (void)awakeFromNib { |
| @@ -261,20 +184,20 @@ | @@ -261,20 +184,20 @@ | ||
| 261 | } | 184 | } |
| 262 | 185 | ||
| 263 | #pragma mark - 响应方法 | 186 | #pragma mark - 响应方法 |
| 264 | -- (void)btnDidClicked:(UIButton *)btn{ | ||
| 265 | - if (self.delegate && [self.delegate respondsToSelector:@selector(cell:clickedButtonWithType:tag:)]) { | ||
| 266 | - [self.delegate cell:self clickedButtonWithType:self.model.type tag:btn.tag]; | 187 | +- (void)allDidClicked:(UIButton *)btn{ |
| 188 | + if (self.delegate && [self.delegate respondsToSelector:@selector(cell:didSelectItemAtItem:)]) { | ||
| 189 | + [self.delegate cell:self didSelectItemAtItem:0]; | ||
| 267 | } | 190 | } |
| 268 | } | 191 | } |
| 269 | 192 | ||
| 270 | -- (void)allDidClicked:(UIButton *)btn{ | ||
| 271 | - if (self.delegate && [self.delegate respondsToSelector:@selector(cell:clickedButtonWithType:tag:)]) { | ||
| 272 | - [self.delegate cell:self clickedButtonWithType:CNLiveMineCellTypeOrder tag:10000]; | 193 | +#pragma mark - 懒加载 |
| 194 | +- (NSMutableArray *)buttons { | ||
| 195 | + if (!_buttons) { | ||
| 196 | + _buttons = [NSMutableArray array]; | ||
| 273 | } | 197 | } |
| 274 | - | 198 | + return _buttons; |
| 275 | } | 199 | } |
| 276 | 200 | ||
| 277 | -#pragma mark - 懒加载 | ||
| 278 | - (UIView *)bgView{ | 201 | - (UIView *)bgView{ |
| 279 | if (!_bgView) { | 202 | if (!_bgView) { |
| 280 | _bgView = [[UIView alloc] init]; | 203 | _bgView = [[UIView alloc] init]; |
| @@ -284,10 +207,11 @@ | @@ -284,10 +207,11 @@ | ||
| 284 | } | 207 | } |
| 285 | return _bgView; | 208 | return _bgView; |
| 286 | } | 209 | } |
| 210 | + | ||
| 287 | - (UIButton *)titleButton{ | 211 | - (UIButton *)titleButton{ |
| 288 | if (!_titleButton) { | 212 | if (!_titleButton) { |
| 289 | _titleButton = [UIButton buttonWithType:UIButtonTypeCustom]; | 213 | _titleButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 290 | - _titleButton.titleLabel.font = [UIFont boldSystemFontOfSize:16]; | 214 | + _titleButton.titleLabel.font = UIFontBoldCNMake(15.0); |
| 291 | [_titleButton setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal]; | 215 | [_titleButton setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal]; |
| 292 | _titleButton.adjustsImageWhenHighlighted = NO; | 216 | _titleButton.adjustsImageWhenHighlighted = NO; |
| 293 | } | 217 | } |
| @@ -302,7 +226,7 @@ | @@ -302,7 +226,7 @@ | ||
| 302 | UIImage *xw_image = [self getImageWithImageName:@"mine_all_front" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; | 226 | UIImage *xw_image = [self getImageWithImageName:@"mine_all_front" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; |
| 303 | [_allButton setImage:xw_image forState:UIControlStateNormal]; | 227 | [_allButton setImage:xw_image forState:UIControlStateNormal]; |
| 304 | [_allButton setImage:xw_image forState:UIControlStateHighlighted]; | 228 | [_allButton setImage:xw_image forState:UIControlStateHighlighted]; |
| 305 | - _allButton.titleLabel.font = [UIFont systemFontOfSize:12]; | 229 | + _allButton.titleLabel.font = UIFontCNMake(12.0); |
| 306 | [_allButton setTitleColor:[UIColor colorWithRed:190.0/255.0 green:190.0/255.0 blue:190.0/255.0 alpha:1.0] forState:UIControlStateNormal]; | 230 | [_allButton setTitleColor:[UIColor colorWithRed:190.0/255.0 green:190.0/255.0 blue:190.0/255.0 alpha:1.0] forState:UIControlStateNormal]; |
| 307 | _allButton.adjustsImageWhenHighlighted = NO; | 231 | _allButton.adjustsImageWhenHighlighted = NO; |
| 308 | [_allButton addTarget:self action:@selector(allDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | 232 | [_allButton addTarget:self action:@selector(allDidClicked:) forControlEvents:UIControlEventTouchUpInside]; |
| @@ -322,25 +246,69 @@ | @@ -322,25 +246,69 @@ | ||
| 322 | return _line; | 246 | return _line; |
| 323 | } | 247 | } |
| 324 | 248 | ||
| 325 | -#pragma mark - 私有方法 | ||
| 326 | -- (UIButton *)createButtonWithFrame:(CGRect)frame title:(NSString *)title image:(NSString *)image tag:(NSInteger)tag{ | ||
| 327 | - UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 328 | - btn.tag = tag; | ||
| 329 | - btn.frame = frame; | ||
| 330 | - btn.titleLabel.font = [UIFont systemFontOfSize:13]; | ||
| 331 | - btn.titleLabel.textAlignment = NSTextAlignmentCenter; | ||
| 332 | - btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示 | ||
| 333 | - | ||
| 334 | - [btn setTitle:title forState:UIControlStateNormal]; | ||
| 335 | - [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 336 | - UIImage *xw_image = [self getImageWithImageName:image bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; | ||
| 337 | - [btn setImage:xw_image forState:UIControlStateNormal]; | ||
| 338 | - btn.adjustsImageWhenHighlighted = NO; | ||
| 339 | - [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 340 | - btn.titleEdgeInsets = UIEdgeInsetsMake(btn.imageView.frame.size.height+self.model.margin, -btn.imageView.frame.size.width, 0, 0); | ||
| 341 | - btn.imageEdgeInsets = UIEdgeInsetsMake(-btn.titleLabel.bounds.size.height, 0, self.model.margin, -btn.titleLabel.bounds.size.width); | ||
| 342 | - return btn; | ||
| 343 | - | 249 | +- (UICollectionView *)collectionView{ |
| 250 | + if(!_collectionView){ | ||
| 251 | + UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; | ||
| 252 | + //设置CollectionView的属性 | ||
| 253 | + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-2*self.model.margin, self.model.height-(50+self.model.margin)) collectionViewLayout:flowLayout]; | ||
| 254 | + _collectionView.delegate = self; | ||
| 255 | + _collectionView.dataSource = self; | ||
| 256 | + _collectionView.scrollEnabled = NO; | ||
| 257 | + _collectionView.backgroundColor = [UIColor clearColor]; | ||
| 258 | + _collectionView.showsVerticalScrollIndicator = NO; | ||
| 259 | + _collectionView.showsHorizontalScrollIndicator = NO; | ||
| 260 | + [_collectionView registerClass:[CNLiveMineButtonCell class] forCellWithReuseIdentifier:kCNLiveMineButtonCell]; | ||
| 261 | + } | ||
| 262 | + return _collectionView; | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | +#pragma mark - 代理 | ||
| 266 | +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { | ||
| 267 | + switch (self.model.type) { | ||
| 268 | + case CNLiveMineCellTypeOrder: | ||
| 269 | + { | ||
| 270 | + return CGSizeMake((SCREEN_WIDTH-4*self.model.margin-4*self.model.margin)/5.0, self.model.itemHeight); | ||
| 271 | + } | ||
| 272 | + break; | ||
| 273 | + | ||
| 274 | + case CNLiveMineCellTypeTool: | ||
| 275 | + { | ||
| 276 | + return CGSizeMake((SCREEN_WIDTH-4*self.model.margin-3*self.model.margin)/4.0, self.model.itemHeight); | ||
| 277 | + } | ||
| 278 | + break; | ||
| 279 | + | ||
| 280 | + case CNLiveMineCellTypeGoods: | ||
| 281 | + { | ||
| 282 | + return CGSizeMake(SCREEN_WIDTH-4*self.model.margin, self.model.itemHeight); | ||
| 283 | + } | ||
| 284 | + break; | ||
| 285 | + | ||
| 286 | + case CNLiveMineCellTypeSports: | ||
| 287 | + { | ||
| 288 | + return CGSizeMake((SCREEN_WIDTH-4*self.model.margin-3*self.model.margin)/4.0, self.model.itemHeight); | ||
| 289 | + } | ||
| 290 | + break; | ||
| 291 | + } | ||
| 292 | +} | ||
| 293 | + | ||
| 294 | +- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { | ||
| 295 | + return UIEdgeInsetsMake(self.model.margin, 0, self.model.margin, 0); | ||
| 296 | +} | ||
| 297 | + | ||
| 298 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { | ||
| 299 | + return self.model.buttons.count; | ||
| 300 | +} | ||
| 301 | + | ||
| 302 | +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { | ||
| 303 | + CNLiveMineButtonCell *cell = (CNLiveMineButtonCell *)[collectionView dequeueReusableCellWithReuseIdentifier:kCNLiveMineButtonCell forIndexPath:indexPath]; | ||
| 304 | + cell.model = self.model.buttons[indexPath.row]; | ||
| 305 | + return cell; | ||
| 306 | +} | ||
| 307 | + | ||
| 308 | +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ | ||
| 309 | + if (self.delegate && [self.delegate respondsToSelector:@selector(cell:didSelectItemAtItem:)]) { | ||
| 310 | + [self.delegate cell:self didSelectItemAtItem:indexPath.item]; | ||
| 311 | + } | ||
| 344 | } | 312 | } |
| 345 | 313 | ||
| 346 | @end | 314 | @end |
CNLiveMineModule/Classes/View/CNLiveMineHeaderView.m
| @@ -287,23 +287,19 @@ static const NSInteger margin = 20; | @@ -287,23 +287,19 @@ static const NSInteger margin = 20; | ||
| 287 | - (void)headerTapDidClicked:(UITapGestureRecognizer *)tap{ | 287 | - (void)headerTapDidClicked:(UITapGestureRecognizer *)tap{ |
| 288 | if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { | 288 | if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { |
| 289 | [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeUerInfo]; | 289 | [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeUerInfo]; |
| 290 | - | ||
| 291 | } | 290 | } |
| 292 | - | ||
| 293 | } | 291 | } |
| 292 | + | ||
| 294 | - (void)nameTapDidClicked:(UITapGestureRecognizer *)tap{ | 293 | - (void)nameTapDidClicked:(UITapGestureRecognizer *)tap{ |
| 295 | if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { | 294 | if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { |
| 296 | [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeCode]; | 295 | [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeCode]; |
| 297 | - | ||
| 298 | } | 296 | } |
| 299 | - | ||
| 300 | } | 297 | } |
| 301 | 298 | ||
| 302 | - (void)setInteractionEnabled:(BOOL)interactionEnabled{ | 299 | - (void)setInteractionEnabled:(BOOL)interactionEnabled{ |
| 303 | _interactionEnabled = interactionEnabled; | 300 | _interactionEnabled = interactionEnabled; |
| 304 | _sign.userInteractionEnabled = interactionEnabled; | 301 | _sign.userInteractionEnabled = interactionEnabled; |
| 305 | _witness.userInteractionEnabled = interactionEnabled; | 302 | _witness.userInteractionEnabled = interactionEnabled; |
| 306 | - | ||
| 307 | } | 303 | } |
| 308 | 304 | ||
| 309 | - (void)signDidClicked:(UIButton *)btn{ | 305 | - (void)signDidClicked:(UIButton *)btn{ |