You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
4.3 KiB
167 lines
4.3 KiB
// |
|
// addressCell.m |
|
// b |
|
// |
|
// Created by kaidan on 2017/1/12. |
|
// Copyright © 2017年 kaidan. All rights reserved. |
|
// |
|
|
|
#import "ContactCell.h" |
|
#import "Masonry.h" |
|
|
|
#import "myHelper.h" |
|
|
|
@interface ContactCell () |
|
|
|
@property(nonatomic,strong)UILabel* tagLab; |
|
|
|
@end |
|
|
|
@implementation ContactCell |
|
|
|
|
|
|
|
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ |
|
|
|
if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { |
|
|
|
[self addSubViews]; |
|
} |
|
|
|
return self; |
|
} |
|
|
|
-(UILabel *)tagLab{ |
|
if (!_tagLab) { |
|
_tagLab = [[UILabel alloc] init]; |
|
} |
|
return _tagLab; |
|
} |
|
|
|
-(UIImageView *)img_Head{ |
|
if (!_img_Head) { |
|
_img_Head = [[UIImageView alloc] init]; |
|
} |
|
return _img_Head; |
|
} |
|
|
|
-(UILabel *)label_Name{ |
|
if (!_label_Name) { |
|
_label_Name = [[UILabel alloc] init]; |
|
_label_Name.font = [myHelper fixFoneSize:19 font:_label_Name.font]; |
|
} |
|
|
|
return _label_Name; |
|
} |
|
|
|
-(UILabel *)label_Phone{ |
|
if (!_label_Phone) { |
|
_label_Phone = [[UILabel alloc] init]; |
|
} |
|
return _label_Phone; |
|
} |
|
|
|
- (void)layoutSubviews { |
|
[super layoutSubviews]; |
|
|
|
[self layoutIfNeeded]; |
|
self.img_Head.layer.masksToBounds = YES; |
|
self.img_Head.layer.cornerRadius = 8; |
|
} |
|
|
|
-(void)addSubViews{ |
|
|
|
UILabel* nameLab = [[UILabel alloc] init]; |
|
nameLab.text = @"昵称:"; |
|
nameLab.font = [myHelper fixFoneSize:19 font:nameLab.font]; |
|
|
|
|
|
UILabel* lab = [[UILabel alloc] init]; |
|
lab.text = @"号码:"; |
|
lab.textColor = [UIColor grayColor]; |
|
|
|
self.tagLab.textAlignment = NSTextAlignmentCenter; |
|
self.tagLab.layer.borderColor = RGB(255, 126, 0).CGColor; |
|
self.tagLab.layer.borderWidth = 1; |
|
self.tagLab.layer.masksToBounds = YES; |
|
self.tagLab.layer.cornerRadius = 2; |
|
|
|
|
|
self.label_Phone.textColor = [UIColor grayColor]; |
|
|
|
[self addSubview:self.img_Head]; |
|
[self addSubview:nameLab]; |
|
[self addSubview:self.label_Name]; |
|
[self addSubview:lab]; |
|
[self addSubview:self.label_Phone]; |
|
[self addSubview:self.tagLab]; |
|
|
|
|
|
[self.img_Head mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.width.height.equalTo(@60); |
|
make.top.left.equalTo(@10); |
|
}]; |
|
|
|
[nameLab mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.equalTo(@10); |
|
make.height.equalTo(@20); |
|
make.width.equalTo(@40); |
|
make.left.mas_equalTo(self.img_Head.mas_right).offset(5); |
|
}]; |
|
|
|
|
|
[self.label_Name mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.mas_equalTo(nameLab.mas_top); |
|
make.left.mas_equalTo(nameLab.mas_right).offset(5); |
|
make.height.mas_equalTo(@20); |
|
}]; |
|
|
|
[self.tagLab mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.height.equalTo(nameLab); |
|
make.width.greaterThanOrEqualTo(@60); |
|
make.left.mas_equalTo(self.label_Name.mas_right).offset(5); |
|
}]; |
|
|
|
[lab mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.mas_equalTo(nameLab.mas_bottom); |
|
make.left.height.equalTo(nameLab); |
|
make.width.mas_equalTo(@40); |
|
}]; |
|
|
|
[self.label_Phone mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.height.top.equalTo(lab); |
|
make.left.mas_equalTo(lab.mas_right).offset(5); |
|
make.width.mas_equalTo(@150); |
|
}]; |
|
|
|
|
|
self.label_Name.font = [UIFont systemFontOfSize:13]; |
|
self.tagLab.font = [UIFont systemFontOfSize:13]; |
|
lab.font = [UIFont systemFontOfSize:13]; |
|
self.label_Phone.font = [UIFont systemFontOfSize:13]; |
|
nameLab.font = [UIFont systemFontOfSize:13]; |
|
} |
|
|
|
-(void)setType:(ContactType)type{ |
|
_type = type; |
|
|
|
switch (type) { |
|
case ContactTypeManager: |
|
self.tagLab.hidden = NO; |
|
self.tagLab.text = @"管理员"; |
|
self.tagLab.textColor = [UIColor whiteColor]; |
|
self.tagLab.backgroundColor = RGB(255, 126, 0); |
|
break; |
|
case ContactTypeMember: |
|
self.tagLab.hidden = NO; |
|
self.tagLab.text = @"成员"; |
|
self.tagLab.textColor = RGB(255, 126, 0); |
|
self.tagLab.backgroundColor = [UIColor whiteColor]; |
|
break; |
|
case ContactTypeWhiteContact: |
|
self.tagLab.hidden = YES; |
|
break; |
|
} |
|
} |
|
|
|
@end
|
|
|