// // HeadinformationCell.m // jitao // // Created by 罗云飞 on 2017/12/6. // Copyright © 2017年 罗云飞. All rights reserved. // #import "HeadinformationCell.h" @implementation HeadinformationCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = NewNavigationColor; UIImageView *image = [UIImageView new]; [image setImage:[UIImage imageNamed:@"我的背景图"]]; [self.contentView addSubview:image]; image.sd_layout .leftEqualToView(self.contentView) .rightEqualToView(self.contentView) .heightIs(fitScreenHeight(133)) .topEqualToView(self.contentView); UIView *view = [UIView new]; view.backgroundColor = NewWhiteColor; //添加两个边阴影 view.layer.shadowColor = [UIColor blackColor].CGColor; view.layer.shadowOffset = CGSizeMake(5, 5); view.layer.shadowOpacity = 1; view.layer.shadowRadius = 9.0; view.layer.cornerRadius = 9.0; view.clipsToBounds = NO; [self.contentView addSubview:view]; ViewRadius(view, 5); view.sd_layout .leftSpaceToView(self.contentView, 15) .topSpaceToView(self.contentView, image.height/2) .rightSpaceToView(self.contentView, 15) .heightIs(fitScreenHeight(90)); _headimage = [UIImageView new]; _headimage.backgroundColor = NewClearColor; [self.contentView addSubview:_headimage]; ViewBorderRadius(_headimage, fitScreenWidth(80)/2, 2, [UIColor colorWithString:@"#ececec"]); _headimage.sd_layout .centerXEqualToView(self.contentView) .topSpaceToView(self.contentView, image.height/2-fitScreenWidth(80)/2) .heightIs(fitScreenWidth(80)) .widthIs(fitScreenWidth(80)); _nickname = [UILabel new]; _nickname.textColor = NewBlackColor; _nickname.font = NewFont(fitScreenWidth(14)); _nickname.textAlignment = NSTextAlignmentCenter; [self.contentView addSubview:_nickname]; _nickname.sd_layout .centerXEqualToView(self.contentView) .topSpaceToView(_headimage, fitScreenWidth(15)) .heightIs(13) .widthIs(SCREEN_WIDTH); } return self; } - (void)assignment:(NSString *)name headurl:(NSString *)url { if ([UserHelper isLogin]) { NSLog(@"%@",@"已登录"); if([name isEqual:[NSNull null]]) { _nickname.text = name; }else{ _nickname.text = name; } [_headimage sd_setImageWithURL:NewURL([url mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"用户头像默认")]; }else{ NSLog(@"%@",@"未登录"); _nickname.text = @"登录/注册"; [_headimage sd_setImageWithURL:NewURL(@"") placeholderImage:NewImageNamed(@"用户头像默认")]; } } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end