Thank you for your excellent project!
I have a UIImageView(bubble view) in root view. the UIImageView has a DTAttributedLabel as its subview.
The DTAttributedLabel could be one line or multi-line。When it is one line, I want to display the bubble view's size just fit to the NSAttributedString.
so, I need to set width of the bubble view, and I need to know the real width of the NSAttributedString. How could I do that?
I will add a method next week to get the minimum size needed to fit a layout frame's text.
Thank you! Waiting for your good news!
@shishirui Please try out the latest stuff in 9ca69be.
To achieve the desired effect I think you would:
If the text is long enough to break on a line then the width will be close to the original width, but never more. If the text is short then the width will be reduced to fit.
Right now this causes two layout passes, but for short texts like you would have in a label the performance hit should not be noticeable.
I have try the lastest version of your code. It is works well for me. Thank you for your hard work!
The method sizeToFit can resize the DTAttributedLabel to the suitable width, but not height. It is enough to me!
@shishirui actually it should also shrink to the minimum height. I need to change that.
@Cocoanetics Wow... If it can shrink to the minimum height, it well be perfect!
adjusted intrinsicContentFrame to calculate height also to fit
previously it didn't adjust the height to be as small as possible #334
I made a change that should cause a sizeToFit on DTAttributedLabel to also shrink to minimum height.
@shishirui please confirm that it now shrinks the height and if you are happy close the issue.
@Cocoanetics It can shrinks the height now. So wonderful! Thank you so much!
I try to use this, But the problem is how do I calculate the height in advance and not initailzed a DTAttributedLabel