LogShareTableViewCell.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // LogShareTableViewCell.m
  3. // IBOSS
  4. //
  5. // Created by Dongke on 15/11/4.
  6. // Copyright © 2015年 elongtian. All rights reserved.
  7. //
  8. #import "LogShareTableViewCell.h"
  9. #import "LogShareAndCommentInfoModel.h"
  10. @implementation LogShareTableViewCell
  11. -(void)parseInfoModel:(LogShareAndCommentInfoModel*)model{
  12. CGFloat xpadding =10;
  13. CGFloat ypadding =8;
  14. NSDictionary *logDict = @{NSFontAttributeName:kTextFont};
  15. _btnSelect=[UIButton buttonWithType:UIButtonTypeCustom];
  16. _btnSelect.frame=CGRectMake(8,33, 20,20);
  17. [_btnSelect addTarget:self action:@selector(btnGoCheck) forControlEvents:UIControlEventTouchUpInside];
  18. [self.contentView addSubview:_btnSelect];
  19. //用户名frame
  20. NSString *titleUserCode=@"用户编码:";
  21. CGRect titleUserCodeFrame = [titleUserCode textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:logDict];
  22. titleUserCodeFrame.origin.x =CGRectGetMaxX(_btnSelect.frame)+xpadding;
  23. titleUserCodeFrame.origin.y = ypadding;
  24. UILabel *lblTitleUserCode=[[UILabel alloc]init];
  25. lblTitleUserCode.backgroundColor = [UIColor clearColor];
  26. lblTitleUserCode.frame=titleUserCodeFrame;
  27. lblTitleUserCode.text=titleUserCode;
  28. lblTitleUserCode.textColor = [UIColor lightGrayColor];
  29. lblTitleUserCode.font =kTextFont;
  30. [self.contentView addSubview:lblTitleUserCode];
  31. NSString *userCode= [model userCode];
  32. CGRect userCodeFrame = [userCode textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:logDict];
  33. userCodeFrame.origin.x =CGRectGetMaxX(titleUserCodeFrame)+xpadding;
  34. userCodeFrame.origin.y = ypadding;
  35. _lblUserCode=[[UILabel alloc]init];
  36. _lblUserCode.backgroundColor = [UIColor clearColor];
  37. _lblUserCode.frame=userCodeFrame;
  38. _lblUserCode.text=userCode;
  39. _lblUserCode.numberOfLines=0;
  40. _lblUserCode.textColor = [UIColor lightGrayColor];
  41. _lblUserCode.font =kTextFont;
  42. [self.contentView addSubview:_lblUserCode];
  43. NSString *titleUserName=@"用户姓名:";
  44. CGRect titleUserNameFrame = [titleUserName textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:logDict];
  45. titleUserNameFrame.origin.x =CGRectGetMaxX(_btnSelect.frame)+xpadding;
  46. titleUserNameFrame.origin.y = CGRectGetMaxY(titleUserCodeFrame)+ypadding;
  47. UILabel *lblTitleUserName=[[UILabel alloc]init];
  48. lblTitleUserName.backgroundColor = [UIColor clearColor];
  49. lblTitleUserName.frame=titleUserNameFrame;
  50. lblTitleUserName.text=titleUserName;
  51. lblTitleUserName.textColor = [UIColor lightGrayColor];
  52. lblTitleUserName.font =kTextFont;
  53. [self.contentView addSubview:lblTitleUserName];
  54. //用户名frame
  55. NSString *userName= [model userName];
  56. CGRect userNameFrame = [userName textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:logDict];
  57. userNameFrame.origin.x =CGRectGetMaxX(titleUserNameFrame)+xpadding;
  58. userNameFrame.origin.y = CGRectGetMaxY(titleUserCodeFrame)+ypadding;
  59. _lblUserName=[[UILabel alloc]init];
  60. _lblUserName.backgroundColor = [UIColor clearColor];
  61. _lblUserName.frame=userNameFrame;
  62. _lblUserName.numberOfLines=0;
  63. _lblUserName.text=userName;
  64. _lblUserName.textColor = [UIColor lightGrayColor];
  65. _lblUserName.font =kTextFont;
  66. [self.contentView addSubview:_lblUserName];
  67. NSString *titleOrganization=@"所属部门:";
  68. CGRect titleOrganizationFrame = [titleOrganization textRectWithSize:CGSizeMake(100, MAXFLOAT) attributes:logDict];
  69. titleOrganizationFrame.origin.x =CGRectGetMaxX(_btnSelect.frame)+xpadding;
  70. titleOrganizationFrame.origin.y = CGRectGetMaxY(titleUserNameFrame)+ypadding;
  71. UILabel *lblTitleOrganization=[[UILabel alloc]init];
  72. lblTitleOrganization.backgroundColor = [UIColor clearColor];
  73. lblTitleOrganization.frame=titleOrganizationFrame;
  74. lblTitleOrganization.text=titleOrganization;
  75. lblTitleOrganization.textColor = [UIColor lightGrayColor];
  76. lblTitleOrganization.font =kTextFont;
  77. [self.contentView addSubview:lblTitleOrganization];
  78. NSString *organization= [model orgName];
  79. CGRect organizationFrame = [organization textRectWithSize:CGSizeMake(200, MAXFLOAT) attributes:logDict];
  80. organizationFrame.origin.x =CGRectGetMaxX(titleOrganizationFrame)+xpadding;
  81. organizationFrame.origin.y = CGRectGetMaxY(titleUserNameFrame)+ypadding;
  82. _lblOrg=[[UILabel alloc]init];
  83. _lblOrg.backgroundColor = [UIColor clearColor];
  84. _lblOrg.frame=organizationFrame;
  85. _lblOrg.text=organization;
  86. _lblOrg.numberOfLines=0;
  87. _lblOrg.textColor = [UIColor lightGrayColor];
  88. _lblOrg.font =kTextFont;
  89. [self.contentView addSubview:_lblOrg];
  90. _separatorView=[UIView new];
  91. _separatorView.frame=CGRectMake(0, CGRectGetMaxY(titleOrganizationFrame)+ypadding, Screen_Width,1);
  92. _separatorView.backgroundColor=LineBackgroundColor;
  93. [self.contentView addSubview:_separatorView];
  94. _userId=model.userId;
  95. }
  96. - (CGFloat)height{
  97. CGFloat height= CGRectGetMaxY(_separatorView.frame);
  98. return height;
  99. }
  100. -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  101. self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
  102. if(self){
  103. }
  104. return self;
  105. }
  106. -(void)btnGoCheck
  107. {
  108. if( [self.delegate respondsToSelector:@selector(btnCheckPressed:)]){
  109. [self.delegate btnCheckPressed:self];
  110. }
  111. }
  112. - (void) setCheckBackground: (BOOL) checked
  113. {
  114. if(!checked)
  115. {
  116. _isSelect=NO;
  117. [_btnSelect setBackgroundImage:[UIImage imageNamed:@"radio_unchecked.png"] forState:UIControlStateNormal];
  118. _btnSelect.imageEdgeInsets=UIEdgeInsetsMake(11,11,11,11);
  119. }
  120. else
  121. {
  122. _isSelect=YES;
  123. [_btnSelect setBackgroundImage:[UIImage imageNamed:@"radio_checked.png"] forState:UIControlStateNormal];
  124. _btnSelect.imageEdgeInsets=UIEdgeInsetsMake(11,11,11,11);
  125. }
  126. }
  127. @end