Commit c94c6e13276b6e683d1ba6fb70b6b6aea4c9befa

Authored by zhangxiaowen
1 parent 089f690c

no message

CNLiveMineModule/Classes/Controller/CNLiveMineController.m
@@ -96,7 +96,6 @@ static const NSInteger kHEIGHT = 240; @@ -96,7 +96,6 @@ static const NSInteger kHEIGHT = 240;
96 } 96 }
97 [self createSubViews]; 97 [self createSubViews];
98 [self loadData]; 98 [self loadData];
99 -  
100 } 99 }
101 100
102 - (void)dealloc { 101 - (void)dealloc {
@@ -112,14 +111,12 @@ static const NSInteger kHEIGHT = 240; @@ -112,14 +111,12 @@ static const NSInteger kHEIGHT = 240;
112 [self.tableView addSubview:headerView]; 111 [self.tableView addSubview:headerView];
113 self.headerView = headerView; 112 self.headerView = headerView;
114 [self.view addSubview:self.soccerBtn]; 113 [self.view addSubview:self.soccerBtn];
115 -  
116 } 114 }
117 115
118 #pragma mark - UITableViewDelegate 116 #pragma mark - UITableViewDelegate
119 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 117 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
120 CNLiveMineModel *model = self.data[indexPath.row]; 118 CNLiveMineModel *model = self.data[indexPath.row];
121 return model.height; 119 return model.height;
122 -  
123 } 120 }
124 121
125 #pragma mark - UITableViewDataSource 122 #pragma mark - UITableViewDataSource
@@ -275,7 +272,6 @@ static const NSInteger kHEIGHT = 240; @@ -275,7 +272,6 @@ static const NSInteger kHEIGHT = 240;
275 - (NSMutableArray *)data { 272 - (NSMutableArray *)data {
276 if (!_data) { 273 if (!_data) {
277 _data = [NSMutableArray array]; 274 _data = [NSMutableArray array];
278 -  
279 } 275 }
280 return _data; 276 return _data;
281 } 277 }
@@ -293,22 +289,20 @@ static const NSInteger kHEIGHT = 240; @@ -293,22 +289,20 @@ static const NSInteger kHEIGHT = 240;
293 _tableView.estimatedSectionFooterHeight = 0; 289 _tableView.estimatedSectionFooterHeight = 0;
294 [_tableView registerClass:[CNLiveMineCell class] forCellReuseIdentifier:kCNLiveMineCell]; 290 [_tableView registerClass:[CNLiveMineCell class] forCellReuseIdentifier:kCNLiveMineCell];
295 _tableView.contentInset = UIEdgeInsetsMake(kHEIGHT, 0, 0, 0); 291 _tableView.contentInset = UIEdgeInsetsMake(kHEIGHT, 0, 0, 0);
296 -  
297 } 292 }
298 return _tableView; 293 return _tableView;
299 } 294 }
  295 +
300 - (UIButton *)soccerBtn{ 296 - (UIButton *)soccerBtn{
301 if(!_soccerBtn){ 297 if(!_soccerBtn){
302 _soccerBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 298 _soccerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
303 _soccerBtn.adjustsImageWhenHighlighted = NO; 299 _soccerBtn.adjustsImageWhenHighlighted = NO;
304 _soccerBtn.frame = CGRectMake(SCREEN_WIDTH-67-10, SCREEN_HEIGHT-71-10-TabBarHeight, 67, 71); 300 _soccerBtn.frame = CGRectMake(SCREEN_WIDTH-67-10, SCREEN_HEIGHT-71-10-TabBarHeight, 67, 71);
305 - UIImage *xw_image = [self xw_getImageName:@"mine_soccer_task" bundle:@"CNLiveMineModule" targetClass:[CNLiveMineController class]]; 301 + UIImage *xw_image = [self xw_getImageName:@"mine_soccer_task" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineController class]];
306 [_soccerBtn setImage:xw_image forState:UIControlStateNormal]; 302 [_soccerBtn setImage:xw_image forState:UIControlStateNormal];
307 [_soccerBtn addTarget:self action:@selector(soccerDidClicked:) forControlEvents:UIControlEventTouchUpInside]; 303 [_soccerBtn addTarget:self action:@selector(soccerDidClicked:) forControlEvents:UIControlEventTouchUpInside];
308 -  
309 } 304 }
310 return _soccerBtn; 305 return _soccerBtn;
311 -  
312 } 306 }
313 307
314 #pragma mark - 响应方法 308 #pragma mark - 响应方法
@@ -324,13 +318,12 @@ static const NSInteger kHEIGHT = 240; @@ -324,13 +318,12 @@ static const NSInteger kHEIGHT = 240;
324 * @param targetClass 类和bundle的同级目录 318 * @param targetClass 类和bundle的同级目录
325 * @return 返回UIImage 319 * @return 返回UIImage
326 */ 320 */
327 -- (UIImage *)xw_getImageName:(NSString *)imageName bundle:(NSString *)bundleName targetClass:(Class)targetClass{ 321 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
328 NSBundle *bundle = [NSBundle bundleForClass:targetClass]; 322 NSBundle *bundle = [NSBundle bundleForClass:targetClass];
329 NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; 323 NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
330 NSBundle *targetBundle = [NSBundle bundleWithURL:url]; 324 NSBundle *targetBundle = [NSBundle bundleWithURL:url];
331 UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil]; 325 UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil];
332 return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; 326 return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
333 -  
334 } 327 }
335 328
336 @end 329 @end
CNLiveMineModule/Classes/View/CNLiveMineCell.m
@@ -21,9 +21,7 @@ @@ -21,9 +21,7 @@
21 @end 21 @end
22 22
23 @implementation CNLiveMineCell 23 @implementation CNLiveMineCell
24 -  
25 -- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier  
26 -{ 24 +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
27 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 25 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
28 if (self) { 26 if (self) {
29 self.contentView.backgroundColor = HexColor(0xf4f4f4); 27 self.contentView.backgroundColor = HexColor(0xf4f4f4);
@@ -31,6 +29,7 @@ @@ -31,6 +29,7 @@
31 } 29 }
32 return self; 30 return self;
33 } 31 }
  32 +
34 - (void)xw_layoutSubviews{ 33 - (void)xw_layoutSubviews{
35 self.bgView = [[UIView alloc] init]; 34 self.bgView = [[UIView alloc] init];
36 _bgView.backgroundColor = [UIColor whiteColor]; 35 _bgView.backgroundColor = [UIColor whiteColor];
@@ -49,12 +48,12 @@ @@ -49,12 +48,12 @@
49 _line.backgroundColor = HexColor(0xebebeb); 48 _line.backgroundColor = HexColor(0xebebeb);
50 [self.contentView addSubview:self.line]; 49 [self.contentView addSubview:self.line];
51 50
52 -  
53 } 51 }
  52 +
54 - (void)setModel:(CNLiveMineModel *)model{ 53 - (void)setModel:(CNLiveMineModel *)model{
55 _model = model; 54 _model = model;
56 [_titleButton setTitle:model.name forState:UIControlStateNormal]; 55 [_titleButton setTitle:model.name forState:UIControlStateNormal];
57 - UIImage *xw_image = [self xw_getImageName:model.pic bundle:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; 56 + UIImage *xw_image = [self xw_getImageName:model.pic bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]];
58 [_titleButton setImage:xw_image forState:UIControlStateNormal]; 57 [_titleButton setImage:xw_image forState:UIControlStateNormal];
59 58
60 switch (model.type) { 59 switch (model.type) {
@@ -161,10 +160,8 @@ @@ -161,10 +160,8 @@
161 } 160 }
162 } 161 }
163 - (void)goods_layoutSubviews{ 162 - (void)goods_layoutSubviews{
164 - //图片相对于button的偏移量  
165 - [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin/2.0, 0, 0)];  
166 - //文字相对于图片的偏移量  
167 - [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin/2.0, 0, 0)]; 163 + [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin, 0, 0)];
  164 + [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin, 0, 0)];
168 165
169 [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { 166 [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
170 make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); 167 make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin);
@@ -199,10 +196,8 @@ @@ -199,10 +196,8 @@
199 196
200 } 197 }
201 - (void)sports_layoutSubviews{ 198 - (void)sports_layoutSubviews{
202 - //图片相对于button的偏移量  
203 - [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin/2.0, 0, 0)];  
204 - //文字相对于图片的偏移量  
205 - [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin/2.0, 0, 0)]; 199 + [_titleButton setImageEdgeInsets:UIEdgeInsetsMake(0, -self.model.margin, 0, 0)];
  200 + [_titleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, self.model.margin, 0, 0)];
206 201
207 [_bgView mas_makeConstraints:^(MASConstraintMaker *make) { 202 [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
208 make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin); 203 make.left.equalTo(self.contentView.mas_left).with.offset(self.model.margin);
@@ -252,7 +247,7 @@ @@ -252,7 +247,7 @@
252 247
253 [btn setTitle:title forState:UIControlStateNormal]; 248 [btn setTitle:title forState:UIControlStateNormal];
254 [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 249 [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
255 - UIImage *xw_image = [self xw_getImageName:image bundle:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; 250 + UIImage *xw_image = [self xw_getImageName:image bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]];
256 [btn setImage:xw_image forState:UIControlStateNormal]; 251 [btn setImage:xw_image forState:UIControlStateNormal];
257 btn.adjustsImageWhenHighlighted = NO; 252 btn.adjustsImageWhenHighlighted = NO;
258 [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside]; 253 [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];
@@ -287,7 +282,7 @@ @@ -287,7 +282,7 @@
287 * @param targetClass 类和bundle的同级目录 282 * @param targetClass 类和bundle的同级目录
288 * @return 返回UIImage 283 * @return 返回UIImage
289 */ 284 */
290 -- (UIImage *)xw_getImageName:(NSString *)imageName bundle:(NSString *)bundleName targetClass:(Class)targetClass{ 285 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
291 NSBundle *bundle = [NSBundle bundleForClass:targetClass]; 286 NSBundle *bundle = [NSBundle bundleForClass:targetClass];
292 NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; 287 NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
293 NSBundle *targetBundle = [NSBundle bundleWithURL:url]; 288 NSBundle *targetBundle = [NSBundle bundleWithURL:url];
CNLiveMineModule/Classes/View/CNLiveMineHeaderView.m
@@ -152,7 +152,7 @@ static const NSInteger margin = 20; @@ -152,7 +152,7 @@ static const NSInteger margin = 20;
152 // 2.添加表情图片 152 // 2.添加表情图片
153 NSTextAttachment *attch = [[NSTextAttachment alloc] init]; 153 NSTextAttachment *attch = [[NSTextAttachment alloc] init];
154 // 表情图片 154 // 表情图片
155 - UIImage *xw_image = [self xw_getImageName:imageName bundle:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; 155 + UIImage *xw_image = [self xw_getImageName:imageName bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]];
156 attch.image = xw_image; 156 attch.image = xw_image;
157 if(isFront){ 157 if(isFront){
158 // 设置图片大小 158 // 设置图片大小
@@ -178,7 +178,7 @@ static const NSInteger margin = 20; @@ -178,7 +178,7 @@ static const NSInteger margin = 20;
178 // 2.添加表情图片 178 // 2.添加表情图片
179 NSTextAttachment *attch = [[NSTextAttachment alloc] init]; 179 NSTextAttachment *attch = [[NSTextAttachment alloc] init];
180 // 表情图片 180 // 表情图片
181 - UIImage *xw_image = [self xw_getImageName:image bundle:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; 181 + UIImage *xw_image = [self xw_getImageName:image bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]];
182 attch.image = xw_image; 182 attch.image = xw_image;
183 // 创建带有图片的富文本 183 // 创建带有图片的富文本
184 NSAttributedString *str = [NSAttributedString attributedStringWithAttachment:attch]; 184 NSAttributedString *str = [NSAttributedString attributedStringWithAttachment:attch];
@@ -196,7 +196,7 @@ static const NSInteger margin = 20; @@ -196,7 +196,7 @@ static const NSInteger margin = 20;
196 - (UIButton *)witness { 196 - (UIButton *)witness {
197 if (!_witness) { 197 if (!_witness) {
198 _witness = [UIButton buttonWithType:UIButtonTypeCustom]; 198 _witness = [UIButton buttonWithType:UIButtonTypeCustom];
199 - UIImage *xw_image = [self xw_getImageName:@"mine_observer" bundle:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; 199 + UIImage *xw_image = [self xw_getImageName:@"mine_observer" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]];
200 _witness.imageView.contentMode = UIViewContentModeScaleAspectFit; 200 _witness.imageView.contentMode = UIViewContentModeScaleAspectFit;
201 [_witness setImage:xw_image forState:UIControlStateNormal]; 201 [_witness setImage:xw_image forState:UIControlStateNormal];
202 _witness.adjustsImageWhenHighlighted = NO; 202 _witness.adjustsImageWhenHighlighted = NO;
@@ -208,7 +208,7 @@ static const NSInteger margin = 20; @@ -208,7 +208,7 @@ static const NSInteger margin = 20;
208 if (!_bgView) { 208 if (!_bgView) {
209 _bgView = [[UIImageView alloc] init]; 209 _bgView = [[UIImageView alloc] init];
210 _bgView.userInteractionEnabled = YES; 210 _bgView.userInteractionEnabled = YES;
211 - UIImage *xw_image = [self xw_getImageName:@"mine_bg" bundle:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; 211 + UIImage *xw_image = [self xw_getImageName:@"mine_bg" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]];
212 _bgView.image = xw_image; 212 _bgView.image = xw_image;
213 } 213 }
214 return _bgView; 214 return _bgView;
@@ -219,7 +219,7 @@ static const NSInteger margin = 20; @@ -219,7 +219,7 @@ static const NSInteger margin = 20;
219 _header.userInteractionEnabled = YES; 219 _header.userInteractionEnabled = YES;
220 _header.layer.masksToBounds = YES; 220 _header.layer.masksToBounds = YES;
221 _header.layer.cornerRadius = 30; 221 _header.layer.cornerRadius = 30;
222 - UIImage *xw_image = [self xw_getImageName:@"default_avatar_y" bundle:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; 222 + UIImage *xw_image = [self xw_getImageName:@"default_avatar_y" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]];
223 [_header sd_setImageWithURL:[NSURL URLWithString:@"头像"] placeholderImage:xw_image]; 223 [_header sd_setImageWithURL:[NSURL URLWithString:@"头像"] placeholderImage:xw_image];
224 __weak typeof(self) weakSelf = self; 224 __weak typeof(self) weakSelf = self;
225 // [_header addGestureTapEventHandle:^(id _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) { 225 // [_header addGestureTapEventHandle:^(id _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
@@ -281,7 +281,7 @@ static const NSInteger margin = 20; @@ -281,7 +281,7 @@ static const NSInteger margin = 20;
281 [_sign setTitle:@"签到赚积分" forState:UIControlStateNormal]; 281 [_sign setTitle:@"签到赚积分" forState:UIControlStateNormal];
282 _sign.titleLabel.font = [UIFont systemFontOfSize:13.0]; 282 _sign.titleLabel.font = [UIFont systemFontOfSize:13.0];
283 [_sign setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 283 [_sign setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
284 - UIImage *xw_image = [self xw_getImageName:@"sign_in_soccer" bundle:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; 284 + UIImage *xw_image = [self xw_getImageName:@"sign_in_soccer" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]];
285 [_sign setImage:xw_image forState:UIControlStateNormal]; 285 [_sign setImage:xw_image forState:UIControlStateNormal];
286 [_sign addTarget:self action:@selector(signDidClicked:) forControlEvents:UIControlEventTouchUpInside]; 286 [_sign addTarget:self action:@selector(signDidClicked:) forControlEvents:UIControlEventTouchUpInside];
287 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_sign.layer.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)]; 287 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_sign.layer.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)];
@@ -314,7 +314,7 @@ static const NSInteger margin = 20; @@ -314,7 +314,7 @@ static const NSInteger margin = 20;
314 * @param targetClass 类和bundle的同级目录 314 * @param targetClass 类和bundle的同级目录
315 * @return 返回UIImage 315 * @return 返回UIImage
316 */ 316 */
317 -- (UIImage *)xw_getImageName:(NSString *)imageName bundle:(NSString *)bundleName targetClass:(Class)targetClass{ 317 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
318 NSBundle *bundle = [NSBundle bundleForClass:targetClass]; 318 NSBundle *bundle = [NSBundle bundleForClass:targetClass];
319 NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; 319 NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
320 NSBundle *targetBundle = [NSBundle bundleWithURL:url]; 320 NSBundle *targetBundle = [NSBundle bundleWithURL:url];