123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- //
- // ClickOKView.m
- // smartRhino
- //
- // Created by tederen on 2019/10/29.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ClickOKView.h"
- #import "DocumentModel.h"
- @interface ClickOKView ()
- @property (nonatomic, strong) UILabel *zanNameLabel;
- @property (nonatomic, strong) UILabel *zanNumLabel;
- @end
- @implementation ClickOKView
- - (instancetype)init{
- self = [super init];
- if (self) {
- [self addSubview:self.zanNameLabel];
- [self addSubview:self.zanNumLabel];
- [self addSubview:self.zansubBtn];
- }
- return self;
- }
- - (void)loadZanListModel:(DocumentModel *)model{
- CGFloat topMagin = 14.5f;
- _zanNameLabel.text = @"闫丹星、王慧源、张丽";
- _zanNameLabel.font = [UIFont systemFontOfSize:16.f];
- _zanNameLabel.textColor = [UIColor hexStringToColor:@"636363"];//UIColorHex(636363);
- CGSize zanNameSize = [_zanNameLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
- _zanNameLabel.frame = CGRectMake(21,topMagin,zanNameSize.width, zanNameSize.height);
-
- _zanNumLabel.text = @"等26人点赞";
- _zanNumLabel.textColor = UIColorHex(1F87DB);
- _zanNumLabel.font = [UIFont systemFontOfSize:16.f];
- CGSize zanNumSize = [_zanNumLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
- _zanNumLabel.frame = CGRectMake(CGRectGetMaxX(_zanNameLabel.frame),topMagin,zanNumSize.width, zanNumSize.height);
-
- _zansubBtn.frame = CGRectMake(kGXScreenWidth -18-21,topMagin,18,14.5);
-
- topMagin += zanNameSize.height;
- topMagin += 14.5;
-
- CGRect frame = self.frame;
- frame.size.height = topMagin;
- self.frame = frame;
-
- }
- - (void)loadZanListModel:(NSArray *)zanArr withAllNumber:(NSInteger)total{
- CGFloat topMagin = 14.5f;
- if (zanArr.count == 0) {
- _zanNameLabel.text = @"";
- }else if((zanArr.count == 1)){
- _zanNameLabel.text = [NSString stringWithFormat:@"%@",zanArr[0][@"UserName"]];
- }else if((zanArr.count == 2)){
- _zanNameLabel.text = [NSString stringWithFormat:@"%@、%@",zanArr[0][@"UserName"],zanArr[1][@"UserName"]];
- }else if((zanArr.count >=3)){
- _zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",zanArr[0][@"UserName"],zanArr[1][@"UserName"],zanArr[2][@"UserName"]];
- }
-
-
- _zanNameLabel.font = [UIFont systemFontOfSize:16.f];
- _zanNameLabel.textColor = [UIColor hexStringToColor:@"636363"];//UIColorHex(636363);
- CGSize zanNameSize = [_zanNameLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
- _zanNameLabel.frame = CGRectMake(21,topMagin,zanNameSize.width, zanNameSize.height);
-
- _zanNumLabel.text = [NSString stringWithFormat:@"等%ld人点赞",(long)total];
- if (zanArr.count == 0) {
- _zanNumLabel.text = @"";
- }
- _zanNumLabel.textColor = UIColorHex(1F87DB);
- _zanNumLabel.font = [UIFont systemFontOfSize:16.f];
- CGSize zanNumSize = [_zanNumLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
- _zanNumLabel.frame = CGRectMake(CGRectGetMaxX(_zanNameLabel.frame),topMagin,zanNumSize.width, zanNumSize.height);
-
- _zansubBtn.frame = CGRectMake(kGXScreenWidth -18-21,topMagin,18,14.5);
-
- topMagin += zanNameSize.height;
- topMagin += 14.5;
-
- CGRect frame = self.frame;
- frame.size.height = topMagin;
- self.frame = frame;
- }
- - (void)gotoZanList:(UIButton *)sender {
- if (self.buttonBlock) {
- self.buttonBlock();
- }
- if ([self respondsToSelector:@selector(didClickOKViewDelegate)]) {
- [self.delegate didClickOKViewDelegate];
- }
- }
- #pragma mark - setter
- - (UILabel *)zanNameLabel{
- if(!_zanNameLabel){
- _zanNameLabel = [UILabel new];
- _zanNameLabel.numberOfLines = 0;
- }
- return _zanNameLabel;
- }
- - (UILabel *)zanNumLabel{
- if(!_zanNumLabel){
- _zanNumLabel = [UILabel new];
- _zanNumLabel.numberOfLines = 0;
- }
- return _zanNumLabel;
- }
- - (TDButton *)zansubBtn{
- if (!_zansubBtn) {
- _zansubBtn = [TDButton buttonWithType:UIButtonTypeCustom];
- [_zansubBtn setImage:IMG(@"icon_xq_zanBtn") forState:UIControlStateNormal];
- [_zansubBtn addTarget:self action:@selector(gotoZanList:) forControlEvents:UIControlEventTouchDown];
- [_zansubBtn setCurrentButtonHotSize:CGSizeZero];
- }
- return _zansubBtn;
- }
- @end
|