42.小项目:微博 V部分

---------- CZStatuesCell.h ----------

#import <UIKit/UIKit.h>


@class CZStatuesFrame;


@interface CZStatuesCell : UITableViewCell


@property (nonatomic, strong) CZStatuesFrame *statuesFrame;

@property (nonatomic, assign) CGFloat cellHeight;


+ (instancetype)cellWithTableView:(UITableView *)tableView;


@end

---------- CZStatuesCell.m ----------

#import "CZStatuesCell.h"

#import "CZStatuse.h"

#import "CZStatuesFrame.h"


@interface CZStatuesCell ()

@property (nonatomic, weak) UIImageView *iconView;

@property (nonatomic, weak) UILabel *nameView;

@property (nonatomic, weak) UIImageView *vipView;

@property (nonatomic, weak) UILabel *textView;

@property (nonatomic, weak) UIImageView *pictureView;


@end


@implementation CZStatuesCell


+ (instancetype)cellWithTableView:(UITableView *)tableView

{

    static NSString * ID = @"weibo";

    CZStatuesCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];

    if (cell == nil)

    {

        cell = [[CZStatuesCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];

    }

    return cell;

}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self)

    {

        [self makeView];

    }

    return self;

}


- (void)makeView

{

    UIImageView *iconView = [[UIImageView alloc] init];

    [self.contentView addSubview:iconView];

    self.iconView = iconView;

    UILabel *nameView = [[UILabel alloc] init];

    [self.contentView addSubview:nameView];

    nameView.font = CZNameFont;

    self.nameView = nameView;

    UIImageView *vipView = [[UIImageView alloc] init];

    vipView.image = [UIImage imageNamed:@"vip"];

    [self.contentView addSubview:vipView];

    self.vipView = vipView;

    UILabel *textView = [[UILabel alloc] init];

    textView.numberOfLines = 0;

    textView.font = CZTextFont;

    [self.contentView addSubview:textView];

    self.textView = textView;

    UIImageView * pictureView = [[UIImageView alloc] init];

    [self.contentView addSubview:pictureView];

    self.pictureView = pictureView;

}


- (void)setStatuesFrame:(CZStatuesFrame *)statuesFrame

{

    _statuesFrame  = statuesFrame;

    [self settingData];

    [self settingFrame];

}


- (void)settingData

{

    CZStatuse *statue = self.statuesFrame.statuse;

    self.iconView.image =  [UIImage imageNamed:statue.icon];

    self.nameView.text = statue.name;

    if (statue.vip)

    {

        self.vipView.hidden = NO;

        self.nameView.textColor = [UIColor redColor];

    }

    else

    {

        self.vipView.hidden = YES;

        self.nameView.textColor = [UIColor blackColor];

    }

    self.textView.text = statue.text;

    if (statue.picture)

    {

        self.pictureView.hidden = NO;

        self.pictureView.image = [UIImage imageNamed:statue.picture];

    }

    else

    {

        self.pictureView.hidden = YES;

    }

}


- (void)settingFrame

{

    self.iconView.frame = self.statuesFrame.iconF;

    self.nameView.frame = self.statuesFrame.nameF;

    self.vipView.frame = self.statuesFrame.vipF;

    self.textView.frame = self.statuesFrame.textF;

    if (self.statuesFrame.statuse.picture)

    {

        self.pictureView.frame = self.statuesFrame.pictureF;

    }

}

@end 

转载于:https://www.cnblogs.com/lixiang2015/p/4719680.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值