#import <UIKit/UIKit.h>
@class YYFriendsModel;
@interface YYfriendCell : UITableViewCell
@property(nonatomic,strong)YYFriendsModel *friends;
+(instancetype)cellWithTableview:(UITableView *)tableView;
@end
YYfriendCell.m文件
复制代码
//
// YYfriendCell.m
// 02-QQ好友列表(基本数据的加载)
//
// Created by apple on 14-5-31.
// Copyright (c) 2014年 itcase. All rights reserved.
//
#import "YYfriendCell.h"
#import "YYFriendsModel.h"
//私有扩展
@interface YYfriendCell()
@end
复制代码
@implementation YYfriendCell
+(YYfriendCell *)cellWithTableview:(UITableView *)tableView
{
static NSString *identifier=@"qq";
YYfriendCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==nil) {
//这里使用系统自带的样式
cell=[[YYfriendCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
NSLog(@"创建一个cell");
}
return cell;
}
-(void)setFriends:(YYFriendsModel *)friends
{
_friends=friends;
//1.设置头像
self.imageView.image=[UIImage imageNamed:_friends.icon];
//2.设置昵称
self.textLabel.text=_friends.name;
//3.设置简介
self.detailTextLabel.text=_friends.intro;
//判断是否是会员
/**
* 这里有个注意点,如果不写else设置为黑色,会怎么样?
*/
if (_friends.isVip) {
[self.textLabel setTextColor:[UIColor redColor]];
}else
{
[self.textLabel setTextColor:[UIColor blackColor]];
}










