Smoothing resizing animation compression compression by priority / size priority in auto-layout

I have a view with a height constraint ≤ constant and a fixed width constraint. Inside it, I have a text view with restrictions on the leading / trailing / top / bottom to this appearance, effectively "docked" inside this view (with only a few points in the field). I have a vertical compression value for vertical content set to 750 and it changes depending on the text content. It grows when I go to the second line, shrinks when I delete a line, etc. However, I want this growth / contraction to be animated. I added this code both to my text view and to the appearance of setFrame: (they are both subclasses):

 -(void)setFrame:(CGRect)frame{ [super setFrame:frame]; [UIView animateWithDuration:0.2 animations:^{ [self layoutIfNeeded]; } completion:nil]; } 

It does not work, it is still not animated. Then I have subclasses of NSLayoutConstraint and redefined its setConstant: method with the same code:

 -(void)setConstant:(CGFloat)constant{ [super setConstant:constant]; if(self.shouldAnimate){ [UIView animateWithDuration:0.2 animations:^{ [self.firstItem layoutIfNeeded]; } completion:nil]; } } 

This does not work either. I set a breakpoint inside these methods and they are not called at all. Apparently, the layout changes at a lower level. How can I revitalize the growth and contraction of my look? One of the options is to disable the priority of resistance to compression of content, calculate the height of my text view when changing text, then set the height attribute manually and animate it. But I don’t want to do this if there is a cleaner solution that includes dynamic / automatic resizing using content compression resistance. Is there a solution?

+7
ios objective-c autolayout ios-autolayout
source share

No one has answered this question yet.

See related questions:

618
Cocoa Auto Detect: Content Crawl and Content Compression Matching
187
What is NSLayoutConstraint "UIView-Encapsulated-Layout-Height" and how do I get it to be recalculated?
177
iOS: multi-line UILabel in auto layout
14
Dynamically view cell size using auto layout constraints
3
UILabel in a subview in UIScrollView is compressed at autorun, even with a compression ratio of 1000
2
Animate a layout constraint by changing its priority value
one
Problem with content content and content compression resistance, auto-detection restrictions
0
IOS auto-layout limitations
0
iOS - auto layout issue with priority restrictions and resistance to compression
0
Content compression resistance, a value of 48 means?

All Articles