Nenhuma Descrição

DetailTransitSouceCell.m 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // DetailTransitSouceCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/7/21.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "DetailTransitSouceCell.h"
  9. @interface DetailTransitSouceCell ()
  10. @property (nonatomic, strong) UIView *middleLine;
  11. @end
  12. @implementation DetailTransitSouceCell
  13. @synthesize linkButton = _linkButton;
  14. @synthesize sourceButton = _sourceButton;
  15. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  16. {
  17. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  18. if (self) {
  19. [self initializeLayout];
  20. self.selectionStyle = UITableViewCellSelectionStyleNone;
  21. }
  22. return self;
  23. }
  24. - (void)initializeLayout{
  25. [self.contentView addSubview:self.middleLine];
  26. [self.contentView addSubview:self.sourceButton];
  27. [self.contentView addSubview:self.linkButton];
  28. [self.middleLine mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.center.equalTo(self.contentView);
  30. make.width.equalTo(@0.5);
  31. make.height.equalTo(@30);
  32. }];
  33. [self.sourceButton mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.top.bottom.equalTo(self.contentView);
  35. make.right.equalTo(self.middleLine.mas_left);
  36. }];
  37. [self.linkButton mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.right.top.bottom.equalTo(self.contentView);
  39. make.left.equalTo(self.middleLine.mas_right);
  40. }];
  41. }
  42. - (UIButton *)createButtonWithTitle:(NSString *)title imageName:(NSString *)imageName
  43. {
  44. NSString *addSpaceTitle = [NSString stringWithFormat:@" %@", title];
  45. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  46. [button setTitle:addSpaceTitle forState:UIControlStateNormal];
  47. [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
  48. [button setTitleColor:UIColorFromRGB(0x676767) forState:UIControlStateNormal];
  49. button.titleLabel.font = [UIFont systemFontOfSize:13];
  50. button.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  51. button.titleLabel.numberOfLines = 1;
  52. return button;
  53. }
  54. - (UIButton *)linkButton
  55. {
  56. if (_linkButton == nil) {
  57. _linkButton = [self createButtonWithTitle:@"" imageName:@"detail_link"];
  58. }
  59. return _linkButton;
  60. }
  61. - (UIButton *)sourceButton
  62. {
  63. if (_sourceButton == nil) {
  64. _sourceButton = [self createButtonWithTitle:@"来源地: " imageName:@"detail_location"];
  65. }
  66. return _sourceButton;
  67. }
  68. - (UIView *)middleLine
  69. {
  70. if (_middleLine == nil){
  71. _middleLine = [[UIView alloc]init];
  72. _middleLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  73. }
  74. return _middleLine;
  75. }
  76. @end