1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- //
- // FKCirclePublicUserCell.m
- // FirstLink
- //
- // Created by ascii on 16/6/8.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKCirclePublicUserCell.h"
- #import "APAvatarImageView.h"
- #import "FKCirclePublicUserItem.h"
- @interface FKCirclePublicUserCell ()
- @property (nonatomic, strong) APAvatarImageView *headPhotoView;
- @property (nonatomic, strong) UILabel *nicknameLabel;
- @end
- @implementation FKCirclePublicUserCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- [self addAllSubviews];
- }
- return self;
- }
- - (void)configWith:(id)item {
- if ([item isKindOfClass:[FKCirclePublicUserItem class]]) {
- FKCirclePublicUserItem *userItem = (FKCirclePublicUserItem *)item;
- [self.headPhotoView sd_setImageWithURL:[NSURL URLWithString:userItem.headURL]];
- self.nicknameLabel.text = userItem.nickname;
- }
- }
- #pragma mark - Method
- + (CGFloat)height {
- return 60;
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self.contentView addSubview:self.headPhotoView];
- [self.headPhotoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(12);
- make.centerY.equalTo(self.contentView).offset(12);
- make.size.mas_equalTo(CGSizeMake(42, 42));
- }];
-
- [self.contentView addSubview:self.nicknameLabel];
- [self.nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headPhotoView.mas_right).offset(14);
- make.centerY.equalTo(self.headPhotoView);
- }];
- }
- #pragma mark - Property
- - (APAvatarImageView*)headPhotoView {
- if (!_headPhotoView) {
- _headPhotoView = [[APAvatarImageView alloc] init];
- _headPhotoView.borderWidth = 0.0;
- _headPhotoView.cornerRadius = 42/2;
- _headPhotoView.borderColor = UIColorFromRGB(0xcccccc);
- _headPhotoView.borderWidth = 1;
- _headPhotoView.image = [UIImage imageNamed:@"AvatarPlaceholderIcon"];
- }
- return _headPhotoView;
- }
- - (UILabel *)nicknameLabel {
- if (!_nicknameLabel) {
- _nicknameLabel = [[UILabel alloc] init];
- _nicknameLabel.textColor = UIColorFromRGB(0x333333);
- _nicknameLabel.font = [UIFont systemFontOfSize:16];
- }
- return _nicknameLabel;
- }
- @end
|