首页 > 其他 > 详细

42.小项目:微博 V部分

时间:2015-08-11 06:50:29      阅读:279      评论:0      收藏:0      [点我收藏+]

---------- 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 

42.小项目:微博 V部分

原文:http://www.cnblogs.com/lixiang2015/p/4719680.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!