ProtocolTableViewCell.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // ProtocolTableViewCell.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/8/10.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "ProtocolTableViewCell.h"
  9. @implementation ProtocolTableViewCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self)
  14. {
  15. self.buttomView = [[UIView alloc]init];
  16. self.nameLabel = [[UILabel alloc]init];
  17. self.protocolButton = [UIButton buttonWithType:UIButtonTypeCustom];
  18. [self addSubview:self.buttomView];
  19. [self.buttomView addSubview:self.nameLabel];
  20. [self.buttomView addSubview:self.protocolButton];
  21. NSString *string = ASLocalizedString(@"竞拍需同意 XXX 竞拍协议");
  22. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:string];
  23. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0]} range:NSMakeRange(0, string.length)];
  24. CGFloat width =[string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width;
  25. self.nameLabel.frame = CGRectMake(0,5,width, 30);
  26. self.nameLabel.attributedText = attr;
  27. self.protocolButton.frame = CGRectMake(width+5,0,60, 40);
  28. [self.protocolButton setTitle:ASLocalizedString(@"查看协议")forState:0];
  29. [self.protocolButton setTitleColor:kBlueColor forState:0];
  30. self.protocolButton.titleLabel.font = [UIFont systemFontOfSize:14];
  31. self.buttomView.frame = CGRectMake(kScreenW/2-(width+65)/2, 0, width+65, 40);
  32. [self.protocolButton addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
  33. }
  34. return self;
  35. }
  36. - (void)buttonClick
  37. {
  38. if (self.delegate)
  39. {
  40. if ([self.delegate respondsToSelector:@selector(goToProtocolController)])
  41. {
  42. [self.delegate goToProtocolController];
  43. }
  44. }
  45. }
  46. @end