// // RADetailLocationModel.m // Apex And Drivers // // Created by Jack on 2018/6/2. // Copyright © 2018年 USAI. All rights reserved. // #import "RADetailLocationModel.h" static const CGFloat SpaceWidth = 60.0f; static const CGFloat SpaceHeight = 38.0f; @implementation RADetailLocationModel { CGFloat _height; } - (void)setLocation:(NSString *)location { _location = location; dispatch_async(dispatch_get_global_queue(0, 0), ^{ [self caculateValueHeight]; }); // NSArray *tmpArr = [location componentsSeparatedByString:@"TEL:"]; // NSString *tmpStr = [tmpArr objectAtIndex:0]; // tmpArr = [tmpStr componentsSeparatedByString:@"\r\n"]; // NSMutableArray *tmpMArr = [tmpArr mutableCopy]; // [tmpMArr removeObjectAtIndex:0]; // tmpStr = [tmpMArr componentsJoinedByString:@" "]; // self.street = tmpStr; } - (CGFloat)height { if (_height <= 0) { [self caculateValueHeight]; } return _height; } - (void)caculateValueHeight { // if (self.location.length == 0) { // return; // } CGFloat w = self.width; if (w <= 0) { w = CGRectGetWidth([UIScreen mainScreen].bounds); } CGFloat h = [self.location boundingRectWithSize:CGSizeMake(w - SpaceWidth, FLT_MAX) options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.0f]} context:nil].size.height; CGFloat navBtnHeight = 40.0f; if (h < navBtnHeight) { // navigation button height h = navBtnHeight; } _height = h + SpaceHeight; if (_height < 80.0f) { _height = 80.0f; } } @end