一看就是令人头疼的UI设计
UILabel *dateLabel = [[UILabel alloc]init];
dateLabel.frame = CGRectMake(UI_View_Width-30-200, 33, 200, 15);
dateLabel.font = [UIFont systemFontOfSize:15];
dateLabel.textColor = BB_White_Color;
dateLabel.textAlignment = NSTextAlignmentRight;
dateLabel.text = [NSString stringWithFormat:@"还款日期 %@",_dataSource[@"date"]];
[cell.contentView addSubview:dateLabel];
UILabel *amountLabel = [[UILabel alloc]init];
amountLabel.frame = CGRectMake(UI_View_Width-30-200, 72, 200, 15);
amountLabel.font = [UIFont systemFontOfSize:15];
amountLabel.textColor = BB_White_Color;
amountLabel.textAlignment = NSTextAlignmentRight;
amountLabel.text = [NSString stringWithFormat:@"借款金额 %@元",_dataSource[@"amount"]];
[cell.contentView addSubview:amountLabel];
if ([dateLabel sizeThatFits:CGSizeMake(UI_View_Width-30, 15)].width>[amountLabel sizeThatFits:CGSizeMake(UI_View_Width-30, 15)].width) {
NSString *space = @" ";
for (int i=0; i<MAXFLOAT; i++) {
amountLabel.text = [NSString stringWithFormat:@"借款金额 %@%@元",space,_dataSource[@"amount"]];
if ([dateLabel sizeThatFits:CGSizeMake(UI_View_Width-30, 15)].width<=[amountLabel sizeThatFits:CGSizeMake(UI_View_Width-30, 15)].width) {
break;
}
space = [space stringByAppendingString:@" "];
}
}else{
NSString *space = @" ";
for (int i=0; i<MAXFLOAT; i++) {
dateLabel.text = [NSString stringWithFormat:@"还款日期 %@%@",space,_dataSource[@"date"]];
if ([dateLabel sizeThatFits:CGSizeMake(UI_View_Width-30, 15)].width>=[amountLabel sizeThatFits:CGSizeMake(UI_View_Width-30, 15)].width) {
break;
}
space = [space stringByAppendingString:@" "];
}
}