自定义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;
}
*)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;
}
相关文章推荐
- IT女孩又来总结了-2015年终总结
- 物流配送记录删除
- Android WebView组件用法详解
- 日经春秋 20160229
- 天声人語 20160229 2月の言葉から
- 连接显示提示语
- linux操作系统初步简介
- VR现在很火,可能给用户带来快感的暂时只有游戏
- Android RecyclerView
- 2014年百度之星资格赛第二题Disk Schedule
- 《Android第一行代码》笔记
- (转)java volatile关键字
- 软件开发模型
- Java回调机制解析
- NodeJs 开发微信公众号(一)准备工作
- 对valueForKeyPath:(NSString *)keyPath方法的理解
- MAC 下面 终端常用指令
- 关于感情
- AngularJS中的事件
- Eclipse安装中文环境