自定义tableViewcell

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

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值