ReplyInfoCell.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // replyInfoCell.m
  3. // IBOSS
  4. //
  5. // Created by guan hong hou on 15/11/16.
  6. // Copyright © 2015年 elongtian. All rights reserved.
  7. //
  8. #import "ReplyInfoCell.h"
  9. #import "ReplyFrame.h"
  10. #define kTextFont [UIFont systemFontOfSize:14]
  11. #define logContentTextFont [UIFont systemFontOfSize:14]
  12. @interface ReplyInfoCell(){
  13. }
  14. @end
  15. @implementation ReplyInfoCell
  16. #pragma mark -公有方法
  17. //初始化tableviewcell的样式
  18. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  19. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  20. return self;
  21. }
  22. #pragma mark -私有方法
  23. //设置回复信息UI
  24. - (void)setReplyInfoData:(ReplyFrame*)replyFrame {
  25. _replyInfo= [replyFrame replyInfo];
  26. if([_replyInfo userName ]!=nil &&[_replyInfo userName].length>0){
  27. _replyUserNameLabel= [UIButton buttonWithType:UIButtonTypeCustom];
  28. _replyUserNameLabel.frame= [replyFrame replierF];
  29. _replyUserNameLabel.titleLabel.font =kTextFont;
  30. _replyUserNameLabel.backgroundColor = [UIColor clearColor];
  31. [_replyUserNameLabel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  32. [_replyUserNameLabel setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  33. NSString *replyUserName=[_replyInfo userName];
  34. NSString *userName=[NSString stringWithFormat:@"%@:",replyUserName];
  35. [_replyUserNameLabel setTitle:userName forState:UIControlStateNormal];
  36. [self.contentView addSubview: _replyUserNameLabel];
  37. [_replyUserNameLabel addTarget:self action:@selector(answerButtonDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  38. if([_replyInfo RepliedUserName]!=nil &&[_replyInfo RepliedUserName].length>0){
  39. BOOL result = [[_replyInfo RepliedUserName] caseInsensitiveCompare:[_replyInfo userName]]== NSOrderedSame;
  40. if(!result){
  41. _replyAtUserNameLabel = [[UILabel alloc] initWithFrame:[replyFrame replierAtF]];
  42. _replyAtUserNameLabel.backgroundColor = [UIColor clearColor];
  43. _replyAtUserNameLabel.textColor = [UIColor colorWithRed:255.0/255.0 green:101.0/255.0 blue:38.0/255.0 alpha:1];
  44. _replyAtUserNameLabel.font =logContentTextFont;
  45. _replyAtUserNameLabel.textAlignment = NSTextAlignmentLeft;
  46. [self.contentView addSubview: _replyAtUserNameLabel];
  47. NSString *atUserName=[_replyInfo RepliedUserName];
  48. NSString *replierAtUserName=[NSString stringWithFormat:@"@%@",atUserName];
  49. _replyAtUserNameLabel.text=replierAtUserName;
  50. _replyContentLabel = [[UILabel alloc] initWithFrame:[replyFrame replyContentF]];
  51. _replyContentLabel.backgroundColor = [UIColor clearColor];
  52. _replyContentLabel.font =logContentTextFont;
  53. _replyContentLabel.numberOfLines=0;
  54. _replyContentLabel.textColor = LabelGrayTextColor;
  55. [self.contentView addSubview:_replyContentLabel];
  56. NSString *replyContent=[_replyInfo replyContent];
  57. _replyContentLabel.text=replyContent;
  58. }
  59. else{
  60. _replyContentLabel = [[UILabel alloc] initWithFrame:[replyFrame replyContentF]];
  61. _replyContentLabel.backgroundColor = [UIColor clearColor];
  62. _replyContentLabel.textColor = LabelGrayTextColor;
  63. _replyContentLabel.font =logContentTextFont;
  64. _replyContentLabel.numberOfLines=0;
  65. [self.contentView addSubview:_replyContentLabel];
  66. NSString *replyContent=[_replyInfo replyContent];
  67. _replyContentLabel.text=replyContent;
  68. }
  69. }
  70. else{
  71. _replyContentLabel = [[UILabel alloc] initWithFrame:[replyFrame replyContentF]];
  72. _replyContentLabel.backgroundColor = [UIColor clearColor];
  73. _replyContentLabel.textColor = LabelGrayTextColor;
  74. _replyContentLabel.font =logContentTextFont;
  75. _replyContentLabel.numberOfLines=0;
  76. [self.contentView addSubview:_replyContentLabel];
  77. NSString *replyContent=[_replyInfo replyContent];
  78. _replyContentLabel.text=replyContent;
  79. }
  80. }
  81. }
  82. //回复按钮点击事件
  83. - (void)answerButtonDidClicked:(UIButton *)sender {
  84. if ([self.delegate respondsToSelector:@selector(ShowOperationView:replyInfo:)]) {
  85. [self.delegate ShowOperationView:sender replyInfo:_replyInfo];
  86. }
  87. }
  88. @end