| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // BuildingCell.m
- // IBOSS
- //
- // Created by 关宏厚 on 2020/7/27.
- // Copyright © 2020 elongtian. All rights reserved.
- //
- #import "BuildingCell.h"
- @interface BuildingCell(){
-
- // 背景色view
- UIView *_viewBackgroud;
- // 宽度
- CGFloat _width;
- // 高度
- CGFloat _lheight ;
- // x坐标
- CGFloat _lblx;
- }
- @end
- @implementation BuildingCell
- /**
- 初始化
-
- @param style <#style description#>
- @param reuseIdentifier <#reuseIdentifier description#>
- @return <#return value description#>
- */
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- _lblx = 20;
- _lheight = 25;
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- _buildingLabelView= [[UILabel alloc] initWithFrame:CGRectMake(_lblx,3,70,_lheight)];
- _buildingLabelView.backgroundColor = [UIColor clearColor];
- _buildingLabelView.textColor = [UIColor blackColor];
- _buildingLabelView .text = @"门 牌 号:";
- _buildingLabelView .font = [UIFont systemFontOfSize:LabelFontOfSize];
- [self addSubview:_buildingLabelView];
-
- _width = Screen_Width - CGRectGetMaxX(_buildingLabelView.frame) - _lblx;
- _buildingView = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_buildingLabelView.frame)+3,3,_width,_lheight)];
- _buildingView.backgroundColor = [UIColor clearColor];
- _buildingView.textColor = [UIColor blackColor];
- _buildingView.textAlignment = NSTextAlignmentLeft;
- _buildingView.font = [UIFont systemFontOfSize:LabelFontOfSize];
- _buildingView.numberOfLines =0;
- [self addSubview: _buildingView];
-
- _viewBackgroud = [UIView new];
- _viewBackgroud.frame = CGRectMake(_lblx, CGRectGetMaxY(_buildingView.frame)+1, Screen_Width-2*_lblx, 1);
- _viewBackgroud.backgroundColor = LineBackgroundColor;
- [self addSubview:_viewBackgroud];
-
- return self;
- }
- /**
- 重新设置地址的高度
-
- @param address <#address description#>
- */
- - (void)setBuilding:(NSString *)building{
- _buildingView.text=building;
-
- NSDictionary *attributesDict = @{NSFontAttributeName:[UIFont systemFontOfSize: LabelFontOfSize]};
- CGRect fra = [building boundingRectWithSize:CGSizeMake(_width, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributesDict context:nil ];
- CGFloat h = fra.size.height;
- if (fra.size.height < _lheight) {
- h = _lheight;
- }else{
- h = fra.size.height;
- }
- _buildingView.frame = CGRectMake(CGRectGetMaxX(_buildingLabelView.frame) + 3,3,_width ,h);
- _viewBackgroud.frame = CGRectMake(_lblx, CGRectGetMaxY(_buildingView.frame) + 2, Screen_Width - 2*_lblx, 1);
- self.height = CGRectGetMaxY(_viewBackgroud.frame);
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- @end
|