WFCUChannelTableViewCell.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // GroupTableViewCell.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/9/13.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUChannelTableViewCell.h"
  9. #import <SDWebImage/SDWebImage.h>
  10. #import "WFCUImage.h"
  11. @interface WFCUChannelTableViewCell()
  12. @property (strong, nonatomic) UIImageView *portrait;
  13. @property (strong, nonatomic) UILabel *name;
  14. @end
  15. @implementation WFCUChannelTableViewCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (UIImageView *)portrait {
  21. if (!_portrait) {
  22. _portrait = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 40, 40)];
  23. [self.contentView addSubview:_portrait];
  24. }
  25. return _portrait;
  26. }
  27. - (UILabel *)name {
  28. if (!_name) {
  29. _name = [[UILabel alloc] initWithFrame:CGRectMake(56, 16, [UIScreen mainScreen].bounds.size.width - 64, 24)];
  30. [self.contentView addSubview:_name];
  31. }
  32. return _name;
  33. }
  34. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  35. [super setSelected:selected animated:animated];
  36. // Configure the view for the selected state
  37. }
  38. - (void)setChannelInfo:(WFCCChannelInfo *)channelInfo {
  39. _channelInfo = channelInfo;
  40. if (channelInfo.name.length == 0) {
  41. self.name.text = WFCString(@"Channel");
  42. } else {
  43. self.name.text = [NSString stringWithFormat:@"%@", channelInfo.name];
  44. }
  45. [self.portrait sd_setImageWithURL:[NSURL URLWithString:[channelInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[WFCUImage imageNamed:@"channel_default_portrait"]];
  46. }
  47. @end