Commit a298cf08111c917814afff75abe231c9bde7a017
1 parent
9bd646f6
no message
Showing
2 changed files
with
69 additions
and
16 deletions
CNLiveMineModule/Classes/View/CNLiveMineCell.m
| @@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
| 15 | @interface CNLiveMineCell() | 15 | @interface CNLiveMineCell() |
| 16 | @property (nonatomic, strong) UIView *bgView; | 16 | @property (nonatomic, strong) UIView *bgView; |
| 17 | @property (nonatomic, strong) UIButton *titleButton; | 17 | @property (nonatomic, strong) UIButton *titleButton; |
| 18 | +@property (nonatomic, strong) UIButton *allButton; | ||
| 18 | 19 | ||
| 19 | @property (nonatomic, strong) UIView *line; | 20 | @property (nonatomic, strong) UIView *line; |
| 20 | 21 | ||
| @@ -31,23 +32,9 @@ | @@ -31,23 +32,9 @@ | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | - (void)xw_layoutSubviews{ | 34 | - (void)xw_layoutSubviews{ |
| 34 | - self.bgView = [[UIView alloc] init]; | ||
| 35 | - _bgView.backgroundColor = [UIColor whiteColor]; | ||
| 36 | - _bgView.layer.masksToBounds = YES; | ||
| 37 | - _bgView.layer.cornerRadius = 5; | ||
| 38 | [self.contentView addSubview:self.bgView]; | 35 | [self.contentView addSubview:self.bgView]; |
| 39 | - | ||
| 40 | - self.titleButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 41 | - _titleButton.titleLabel.font = [UIFont boldSystemFontOfSize:16]; | ||
| 42 | - [_titleButton setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal]; | ||
| 43 | - _titleButton.adjustsImageWhenHighlighted = NO; | ||
| 44 | -// [_titleButton addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 45 | - [self.contentView addSubview:self.titleButton]; | ||
| 46 | - | ||
| 47 | - self.line = [[UIView alloc] init]; | ||
| 48 | - _line.backgroundColor = HexColor(0xebebeb); | 36 | + [self.contentView addSubview:self.titleButton]; |
| 49 | [self.contentView addSubview:self.line]; | 37 | [self.contentView addSubview:self.line]; |
| 50 | - | ||
| 51 | } | 38 | } |
| 52 | 39 | ||
| 53 | - (void)setModel:(CNLiveMineModel *)model{ | 40 | - (void)setModel:(CNLiveMineModel *)model{ |
| @@ -101,6 +88,15 @@ | @@ -101,6 +88,15 @@ | ||
| 101 | make.height.with.offset(50); | 88 | make.height.with.offset(50); |
| 102 | 89 | ||
| 103 | }]; | 90 | }]; |
| 91 | + | ||
| 92 | + [self.contentView addSubview:self.allButton]; | ||
| 93 | + [_allButton mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 94 | + make.top.equalTo(self.titleButton.mas_top); | ||
| 95 | + make.right.equalTo(self.bgView.mas_right).with.offset(-self.model.margin); | ||
| 96 | + make.height.with.offset(50); | ||
| 97 | + | ||
| 98 | + }]; | ||
| 99 | + | ||
| 104 | [_line mas_makeConstraints:^(MASConstraintMaker *make) { | 100 | [_line mas_makeConstraints:^(MASConstraintMaker *make) { |
| 105 | make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); | 101 | make.top.equalTo(self.titleButton.mas_bottom).with.offset(0); |
| 106 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); | 102 | make.left.equalTo(self.bgView.mas_left).with.offset(self.model.margin); |
| @@ -268,12 +264,65 @@ | @@ -268,12 +264,65 @@ | ||
| 268 | // Configure the view for the selected state | 264 | // Configure the view for the selected state |
| 269 | } | 265 | } |
| 270 | 266 | ||
| 267 | +#pragma mark - 响应方法 | ||
| 271 | - (void)btnDidClicked:(UIButton *)btn{ | 268 | - (void)btnDidClicked:(UIButton *)btn{ |
| 272 | if (self.delegate && [self.delegate respondsToSelector:@selector(cell:clickedButtonWithType:tag:)]) { | 269 | if (self.delegate && [self.delegate respondsToSelector:@selector(cell:clickedButtonWithType:tag:)]) { |
| 273 | [self.delegate cell:self clickedButtonWithType:self.model.type tag:btn.tag]; | 270 | [self.delegate cell:self clickedButtonWithType:self.model.type tag:btn.tag]; |
| 274 | } | 271 | } |
| 275 | } | 272 | } |
| 276 | 273 | ||
| 274 | +- (void)allBtnDidClicked:(UIButton *)btn{ | ||
| 275 | + | ||
| 276 | + | ||
| 277 | +} | ||
| 278 | + | ||
| 279 | +#pragma mark - 懒加载 | ||
| 280 | +- (UIView *)bgView{ | ||
| 281 | + if (!_bgView) { | ||
| 282 | + _bgView = [[UIView alloc] init]; | ||
| 283 | + _bgView.backgroundColor = [UIColor whiteColor]; | ||
| 284 | + _bgView.layer.masksToBounds = YES; | ||
| 285 | + _bgView.layer.cornerRadius = 5; | ||
| 286 | + } | ||
| 287 | + return _bgView; | ||
| 288 | +} | ||
| 289 | +- (UIButton *)titleButton{ | ||
| 290 | + if (!_titleButton) { | ||
| 291 | + _titleButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 292 | + _titleButton.titleLabel.font = [UIFont boldSystemFontOfSize:16]; | ||
| 293 | + [_titleButton setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal]; | ||
| 294 | + _titleButton.adjustsImageWhenHighlighted = NO; | ||
| 295 | + } | ||
| 296 | + return _titleButton; | ||
| 297 | + | ||
| 298 | +} | ||
| 299 | + | ||
| 300 | +- (UIButton *)allButton{ | ||
| 301 | + if(!_allButton){ | ||
| 302 | + _allButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 303 | + [_allButton setTitle:@"查看全部" forState:UIControlStateNormal]; | ||
| 304 | + UIImage *xw_image = [self xw_getImageName:@"mine_front" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineCell class]]; | ||
| 305 | + [_allButton setImage:xw_image forState:UIControlStateNormal]; | ||
| 306 | + [_allButton setImage:xw_image forState:UIControlStateHighlighted]; | ||
| 307 | + _allButton.titleLabel.font = [UIFont boldSystemFontOfSize:12]; | ||
| 308 | + [_allButton setTitleColor:[UIColor colorWithRed:200.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:1.0] forState:UIControlStateNormal]; | ||
| 309 | + _allButton.adjustsImageWhenHighlighted = NO; | ||
| 310 | + [_allButton addTarget:self action:@selector(allBtnDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 311 | + | ||
| 312 | + _allButton.titleEdgeInsets = UIEdgeInsetsMake(0, -12, 0, 12); | ||
| 313 | + _allButton.imageEdgeInsets = UIEdgeInsetsMake(0, 50, 0, -50); | ||
| 314 | + | ||
| 315 | + } | ||
| 316 | + return _allButton; | ||
| 317 | +} | ||
| 318 | + | ||
| 319 | +- (UIView *)line{ | ||
| 320 | + if (!_line) { | ||
| 321 | + _line = [[UIView alloc] init]; | ||
| 322 | + _line.backgroundColor = HexColor(0xebebeb); | ||
| 323 | + } | ||
| 324 | + return _line; | ||
| 325 | +} | ||
| 277 | /** | 326 | /** |
| 278 | * 创建图片 | 327 | * 创建图片 |
| 279 | * | 328 | * |
CNLiveMineModule/Classes/View/CNLiveMineNavigationBar.m
| @@ -48,9 +48,12 @@ static const NSInteger margin = 10; | @@ -48,9 +48,12 @@ static const NSInteger margin = 10; | ||
| 48 | 48 | ||
| 49 | NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:14]}; | 49 | NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:14]}; |
| 50 | CGFloat width = [@"张晓文" boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size.width+margin; | 50 | CGFloat width = [@"张晓文" boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size.width+margin; |
| 51 | - | 51 | + if(width >= SCREEN_WIDTH){ |
| 52 | + width = SCREEN_WIDTH-50; | ||
| 53 | + } | ||
| 52 | [_name mas_makeConstraints:^(MASConstraintMaker *make) { | 54 | [_name mas_makeConstraints:^(MASConstraintMaker *make) { |
| 53 | make.left.equalTo(self.mas_left).with.offset((SCREEN_WIDTH-width)/2.0+30); | 55 | make.left.equalTo(self.mas_left).with.offset((SCREEN_WIDTH-width)/2.0+30); |
| 56 | + make.right.mas_lessThanOrEqualTo(self.mas_right).with.offset(-margin); | ||
| 54 | make.top.equalTo(self.mas_top).with.offset(StatusBarHeight); | 57 | make.top.equalTo(self.mas_top).with.offset(StatusBarHeight); |
| 55 | make.bottom.equalTo(self.mas_bottom).with.offset(-0); | 58 | make.bottom.equalTo(self.mas_bottom).with.offset(-0); |
| 56 | make.width.offset(width); | 59 | make.width.offset(width); |
| @@ -91,6 +94,7 @@ static const NSInteger margin = 10; | @@ -91,6 +94,7 @@ static const NSInteger margin = 10; | ||
| 91 | _name = [[UILabel alloc] init]; | 94 | _name = [[UILabel alloc] init]; |
| 92 | _name.userInteractionEnabled = YES; | 95 | _name.userInteractionEnabled = YES; |
| 93 | _name.numberOfLines = 1; | 96 | _name.numberOfLines = 1; |
| 97 | + _name.lineBreakMode = NSLineBreakByTruncatingTail; | ||
| 94 | _name.textColor = [UIColor whiteColor]; | 98 | _name.textColor = [UIColor whiteColor]; |
| 95 | _name.font = [UIFont systemFontOfSize:14]; | 99 | _name.font = [UIFont systemFontOfSize:14]; |
| 96 | _name.text = CNUserShareModel.nickname; | 100 | _name.text = CNUserShareModel.nickname; |