您的位置:首页 > 其它

自定义tableViewcell

2016-02-29 08:58 204 查看
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString
*)reuseIdentifier

{

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

if (self) {

[self
initGUI];

}

return
self;

}

- (void)initGUI

{

self.logo
= [[UIImageView
alloc]
init];

[self.contentView
addSubview:self.logo];

self.label1
= [[UILabel
alloc]
init];

[self.contentView
addSubview:self.label1];

self.label2
= [[UILabel
alloc]
init];

[self.contentView
addSubview:self.label2];

self.label3
= [[UILabel
alloc]
init];

[self.contentView
addSubview:self.label3];

self.img
= [[UIImageView
alloc]
init];

[self.contentView
addSubview:self.img];

self.switchControl
= [[UISwitch
alloc]
init];

[self.contentView
addSubview:self.switchControl];

}

- (void)layoutSubviews

{

[super
layoutSubviews];

for (UIView
*view in
self.contentView.subviews)
{

view.hidden =
YES;

}

switch (_type)
{

//个人中心
显示个人信息

case
1:

{

self.logo.hidden =
NO;

self.logo.frame
= CGRectMake(15,
10,
70,
70);

self.logo.layer.cornerRadius
= 35;

self.logo.layer.masksToBounds
= YES;

[self.logo
sd_setImageWithURL:[NSURL
URLWithString:[UserInfo
shareUser].logo]
placeholderImage:FriendHead];

self.label1.hidden =
NO;

self.label1.frame
= CGRectMake(self.logo.right
+ 10,
self.logo.top
+ 5,
UI_SCREEN_WIDTH -
self.logo.right
- 20 -
25,
20);

self.label1.textColor
= [UIColor
blackColor];

self.label1.text
= [UserInfo
shareUser].nickname;

self.label2.hidden =
NO;

self.label2.frame
= CGRectMake(self.label1.left,
self.logo.bottom
- 25,
self.label1.width,
20);

self.label2.textAlignment
= NSTextAlignmentLeft;

self.label2.textColor
= [UIColor
grayColor];

self.label2.text
= [UserInfo
shareUser].mobile;

}

break;

case
2:

{

self.label1.hidden =
NO;

self.label1.frame
= CGRectMake(15,
0,
UI_SCREEN_WIDTH -
25 -
20 -
25,
self.height);

self.label1.textColor
= [UIColor
blackColor];

self.label1.text
= self.title;

}

break;

case
3:

{

self.label1.hidden =
NO;

self.label1.frame
= CGRectMake(15,
0,
UI_SCREEN_WIDTH -
25 -
20 -
25,
self.height);

self.label1.textColor
= BaseColor;

self.label1.text
= self.title;

}

break;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: