lundi 4 juillet 2016

Objective C: how to resize uitextview height with animation?


I have UITextView (textView) in some other view (extView) in my Objective C project with some text in it. The text in textView is quite long so it could by maximised and minimised. Of course, I'd like to do it with some animation. I change the height of extView with code:

- (void)setExtViewHeight:(CGFloat)newHeight withAnimation:(CGFloat)duration
{
    [self setNeedsUpdateConstraints];
    [UIView animateWithDuration:duration
                     animations:^
                     {
                         self.extViewHeight.constant = newHeight;
                         [self layoutIfNeeded];
                         [self.textView layoutIfNeeded];
                     }
                     completion:^(BOOL finished)
                     {
                         [self layoutSubviews];
                     }
    ];
}

My problem is that animation are actually works only for extView. So when I try to minimise my view the textView jumps to new height and after that extView height is changing with animation. This jump of textView is really annoying and doesn't look good. Could you give me a helping hand, please, what did I do wrong? Why height of textView doesn't follow the animation?


Aucun commentaire:

Enregistrer un commentaire