| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // RADetailMultLineModel.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/6/2.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "RADetailMultLineModel.h"
- static const CGFloat SpaceWidth = 10.0f;
- static const CGFloat SpaceHeight = 12.0f;
- @implementation RADetailMultLineModel {
- CGFloat _height;
- }
- - (void)setValue:(NSString *)value {
- _value = value;
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- [self caculateValueHeight];
- });
- }
- - (CGFloat)height {
- if (_height <= 0) {
- [self caculateValueHeight];
- }
- return _height;
- }
- - (void)caculateValueHeight {
- // if (self.value.length == 0) {
- // return;
- // }
- CGFloat w = self.width;
- if (w <= 0) {
- w = CGRectGetWidth([UIScreen mainScreen].bounds);
- }
-
- CGFloat h = [self.value boundingRectWithSize:CGSizeMake(w - SpaceWidth, FLT_MAX)
- options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
- attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.0f]}
- context:nil].size.height;
- _height = h + SpaceHeight;
- if (_height < 90) {
- _height = 90.0f;
- }
- }
- @end
|