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