No Description

FKCirclePublicUserCell.m 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // FKCirclePublicUserCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/6/8.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCirclePublicUserCell.h"
  9. #import "APAvatarImageView.h"
  10. #import "FKCirclePublicUserItem.h"
  11. @interface FKCirclePublicUserCell ()
  12. @property (nonatomic, strong) APAvatarImageView *headPhotoView;
  13. @property (nonatomic, strong) UILabel *nicknameLabel;
  14. @end
  15. @implementation FKCirclePublicUserCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  17. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  18. self.selectionStyle = UITableViewCellSelectionStyleNone;
  19. [self addAllSubviews];
  20. }
  21. return self;
  22. }
  23. - (void)configWith:(id)item {
  24. if ([item isKindOfClass:[FKCirclePublicUserItem class]]) {
  25. FKCirclePublicUserItem *userItem = (FKCirclePublicUserItem *)item;
  26. [self.headPhotoView sd_setImageWithURL:[NSURL URLWithString:userItem.headURL]];
  27. self.nicknameLabel.text = userItem.nickname;
  28. }
  29. }
  30. #pragma mark - Method
  31. + (CGFloat)height {
  32. return 60;
  33. }
  34. #pragma mark - Layout
  35. - (void)addAllSubviews {
  36. [self.contentView addSubview:self.headPhotoView];
  37. [self.headPhotoView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.equalTo(self.contentView).offset(12);
  39. make.centerY.equalTo(self.contentView).offset(12);
  40. make.size.mas_equalTo(CGSizeMake(42, 42));
  41. }];
  42. [self.contentView addSubview:self.nicknameLabel];
  43. [self.nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.headPhotoView.mas_right).offset(14);
  45. make.centerY.equalTo(self.headPhotoView);
  46. }];
  47. }
  48. #pragma mark - Property
  49. - (APAvatarImageView*)headPhotoView {
  50. if (!_headPhotoView) {
  51. _headPhotoView = [[APAvatarImageView alloc] init];
  52. _headPhotoView.borderWidth = 0.0;
  53. _headPhotoView.cornerRadius = 42/2;
  54. _headPhotoView.borderColor = UIColorFromRGB(0xcccccc);
  55. _headPhotoView.borderWidth = 1;
  56. _headPhotoView.image = [UIImage imageNamed:@"AvatarPlaceholderIcon"];
  57. }
  58. return _headPhotoView;
  59. }
  60. - (UILabel *)nicknameLabel {
  61. if (!_nicknameLabel) {
  62. _nicknameLabel = [[UILabel alloc] init];
  63. _nicknameLabel.textColor = UIColorFromRGB(0x333333);
  64. _nicknameLabel.font = [UIFont systemFontOfSize:16];
  65. }
  66. return _nicknameLabel;
  67. }
  68. @end