MyTDTopicTitleView.m 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // MyTDTopicTitleView.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/31.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicTitleView.h"
  9. #import "MyTDTopicModel.h"
  10. @interface MyTDTopicTitleView()
  11. @property (nonatomic, strong) UILabel *selectKeyLabel;
  12. @property (nonatomic, strong) UILabel *topicTitlelabel;
  13. @property (nonatomic, strong) UILabel *topicContentlabel;
  14. @property (nonatomic, strong) UIView *lineView;
  15. @end
  16. @implementation MyTDTopicTitleView
  17. - (void)loadTopicData:(MyTDTopicModel *)model{
  18. CGFloat topMargin = 17;
  19. self.selectKeyLabel.text = @"标题: ";
  20. self.topicTitlelabel.text = model.topicName;
  21. [ZYCTool setLabel:self.topicTitlelabel withSpace:5 withFont:[UIFont systemFontOfSize:18.f weight:UIFontWeightLight] setLineSpace:0 setTextSpace:0.2];
  22. CGSize workGroupSize = [self.topicTitlelabel sizeThatFits:CGSizeMake(kGXScreenWidth -67-20, 41)];
  23. CGRect workFrame = self.topicTitlelabel.frame;
  24. workFrame.size = workGroupSize;
  25. workFrame.origin.y = topMargin-2;
  26. workFrame.origin.x = 67.5;
  27. self.topicTitlelabel.frame = workFrame;
  28. topMargin += workFrame.size.height;
  29. topMargin += 16.5;
  30. CGRect lineFrame = self.lineView.frame;
  31. lineFrame.origin.y = topMargin;
  32. self.lineView.frame = lineFrame;
  33. topMargin += 16.5;
  34. self.topicContentlabel.text = model.topicContent;
  35. [ZYCTool setLabel:self.topicContentlabel withSpace:5 withFont:[UIFont systemFontOfSize:18.f weight:UIFontWeightThin] setLineSpace:0 setTextSpace:0.2];
  36. CGSize topicContentSize = [self.topicContentlabel sizeThatFits:CGSizeMake(kGXScreenWidth -45,MAXFLOAT)];
  37. self.topicContentlabel.frame = CGRectMake(15, topMargin,topicContentSize.width,topicContentSize.height);
  38. topMargin += topicContentSize.height ;
  39. topMargin += 50;
  40. CGRect frame = self.frame;
  41. frame.size.height = topMargin;
  42. self.frame = frame;
  43. }
  44. - (instancetype)initWithFrame:(CGRect)frame{
  45. self =[super initWithFrame:frame];
  46. if (self) {
  47. UILabel *selectKeyLabel = [[UILabel alloc]initWithFrame:CGRectMake(15.5, 17.5, 70.5, 15.5)];
  48. selectKeyLabel.textColor = UIColorHex(999999);
  49. selectKeyLabel.font = [UIFont systemFontOfSize:16.f];
  50. [self addSubview:selectKeyLabel];
  51. self.selectKeyLabel = selectKeyLabel;
  52. [self addSubview:self.topicTitlelabel];
  53. [self addSubview:self.lineView];
  54. [self addSubview:self.topicContentlabel];
  55. }
  56. return self;
  57. }
  58. - (UILabel *)topicTitlelabel {
  59. if (!_topicTitlelabel) {
  60. _topicTitlelabel = [UILabel new];
  61. _topicTitlelabel.numberOfLines = 0;
  62. }
  63. return _topicTitlelabel;
  64. }
  65. - (UIView *)lineView{
  66. if (!_lineView) {
  67. _lineView = [UIView new];
  68. _lineView.frame = CGRectMake(15, 0,kGXScreenWidth -30, 1);
  69. _lineView.backgroundColor = UIColorHex(B1D8FF);
  70. }
  71. return _lineView;
  72. }
  73. - (UILabel *)topicContentlabel{
  74. if (!_topicContentlabel) {
  75. _topicContentlabel = [UILabel new];
  76. _topicContentlabel.numberOfLines = 0;
  77. }
  78. return _topicContentlabel;
  79. }
  80. @end