diff --git a/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate b/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate index e12dc6b..1e881e0 100644 Binary files a/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate and b/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ManagerDemo/MainView/ListView/LoanListCell.h b/ManagerDemo/MainView/ListView/LoanListCell.h index 2843014..c3aff29 100644 --- a/ManagerDemo/MainView/ListView/LoanListCell.h +++ b/ManagerDemo/MainView/ListView/LoanListCell.h @@ -19,6 +19,7 @@ @property (weak, nonatomic) IBOutlet DTAttributedLabel *percentDtlabel; @property (weak, nonatomic) IBOutlet MRCircularProgressView *percentView; @property (weak, nonatomic) IBOutlet UILabel *typeLabel; +@property (weak, nonatomic) IBOutlet UIImageView *pieImage; -(void)setInfoDic:(NSDictionary *)dic; @end diff --git a/ManagerDemo/MainView/ListView/LoanListCell.m b/ManagerDemo/MainView/ListView/LoanListCell.m index 36336e3..f0185ba 100644 --- a/ManagerDemo/MainView/ListView/LoanListCell.m +++ b/ManagerDemo/MainView/ListView/LoanListCell.m @@ -50,6 +50,11 @@ NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; _percentDtlabel.attributedString = percentString; + CGRect frame = _percentDtlabel.frame; + CGSize size = [_percentDtlabel suggestedFrameSizeToFitEntireStringConstraintedToWidth:_percentDtlabel.frame.size.width]; + frame.size.height = size.height+2; + _percentDtlabel.frame = frame; + _percentDtlabel.center = _pieImage.center; [_percentView setProgress:percent/100.0 animated:NO]; } -(void)setTimeWithString:(NSString*)htmlString @@ -84,11 +89,17 @@ }else if([[dic objectForKey:@"state"] isEqualToString:@"EFFECTED"]){ [self setTimeWithString:@"最近还款日"]; [_percentView setProgress:0 animated:NO]; - NSString* htmlStr = [dic objectForKey:@"descValue"]; + NSString* htmlStr = [NSString stringWithFormat:@"%@ ",[dic objectForKey:@"descValue"]]; + NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; _percentDtlabel.attributedString = percentString; + CGRect frame = _percentDtlabel.frame; + CGSize size = [_percentDtlabel suggestedFrameSizeToFitEntireStringConstraintedToWidth:60.0]; + frame.size.height = size.height+2; + _percentDtlabel.frame = frame; + _percentDtlabel.center = _pieImage.center; _priceLabel.text = [dic objectForKey:@"recRepayDate"]; }else if ( [[dic objectForKey:@"state"] isEqualToString:@"ENABLED"]) { @@ -99,6 +110,11 @@ NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; _percentDtlabel.attributedString = percentString; + CGRect frame = _percentDtlabel.frame; + CGSize size = [_percentDtlabel suggestedFrameSizeToFitEntireStringConstraintedToWidth:_percentDtlabel.frame.size.width]; + frame.size.height = size.height; + _percentDtlabel.frame = frame; + _percentDtlabel.center = _pieImage.center; } diff --git a/ManagerDemo/MainView/ListView/LoanListCell.xib b/ManagerDemo/MainView/ListView/LoanListCell.xib index c2a8be2..af3945c 100644 --- a/ManagerDemo/MainView/ListView/LoanListCell.xib +++ b/ManagerDemo/MainView/ListView/LoanListCell.xib @@ -63,7 +63,7 @@ - + @@ -88,6 +88,7 @@ + diff --git a/Pods/DTCoreText/Core/Source/DTAttributedTextContentView.m b/Pods/DTCoreText/Core/Source/DTAttributedTextContentView.m index 7d5e95f..8ab47ea 100644 --- a/Pods/DTCoreText/Core/Source/DTAttributedTextContentView.m +++ b/Pods/DTCoreText/Core/Source/DTAttributedTextContentView.m @@ -639,7 +639,18 @@ static Class _layerClassToUseForDTAttributedTextContentView = nil; - (CGSize)suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width { - // create a temporary frame, will be cached by the layouter for the given rect +// // create a temporary frame, will be cached by the layouter for the given rect +// CGRect rect = [self _frameForLayoutFrameConstraintedToWidth:width]; +// DTCoreTextLayoutFrame *tmpLayoutFrame = [self.layouter layoutFrameWithRect:rect range:NSMakeRange(0, 0)]; +// +// // assign current layout frame properties to tmpLayoutFrame +// tmpLayoutFrame.numberOfLines = _numberOfLines; +// tmpLayoutFrame.lineBreakMode = _lineBreakMode; +// tmpLayoutFrame.truncationString = _truncationString; +// +// // we have a layout frame and from this we get the needed size +// return CGSizeMake(tmpLayoutFrame.frame.size.width + _edgeInsets.left + _edgeInsets.right, CGRectGetMaxY(tmpLayoutFrame.frame) + _edgeInsets.bottom); + // create a temporary frame, will be cached by the layouter for the given rect CGRect rect = [self _frameForLayoutFrameConstraintedToWidth:width]; DTCoreTextLayoutFrame *tmpLayoutFrame = [self.layouter layoutFrameWithRect:rect range:NSMakeRange(0, 0)]; @@ -648,8 +659,17 @@ static Class _layerClassToUseForDTAttributedTextContentView = nil; tmpLayoutFrame.lineBreakMode = _lineBreakMode; tmpLayoutFrame.truncationString = _truncationString; + // Note: this returns an unreliable measure prior to 4.2 for very long documents + CGSize neededSize = CTFramesetterSuggestFrameSizeWithConstraints(self.layouter.framesetter, CFRangeMake(0, 0), NULL, + CGSizeMake(width, CGFLOAT_MAX), + NULL); + + // round up because generally we don't want non-integer view sizes + neededSize.width = ceilf(neededSize.width); + neededSize.height = ceilf(neededSize.height); // we have a layout frame and from this we get the needed size - return CGSizeMake(tmpLayoutFrame.frame.size.width + _edgeInsets.left + _edgeInsets.right, CGRectGetMaxY(tmpLayoutFrame.frame) + _edgeInsets.bottom); + return CGSizeMake(neededSize.width + _edgeInsets.left + _edgeInsets.right, neededSize.height + _edgeInsets.bottom); + } #pragma mark Properties