Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Animating constraint changes causes the overlay to stretch/shrink until animation completes #37

Open
TimAEllis opened this issue Nov 17, 2016 · 0 comments

Comments

@TimAEllis
Copy link

I'm currently using SAMTextView in a full-screen modal. Whenever the keyboard appears or disappears, I animate the updated constraint. While the animation is taking the place, the placeholder text shrinks while the resize is taking place but then is redrawn after the animation is complete. I've attached a snippet of code which causes the issue.

- (void)keyboardWillShow:(NSNotification *)note {
	NSDictionary *userInfo = [note userInfo];
	CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
	// Check if the constraint is the same as what it is about to be set to, and abort if it is.
	if (self.descriptionBottomConstraint.constant == -(keyboardFrame.size.height)) {
		return;
	}
	double animationDuration = [((NSNumber *)userInfo[UIKeyboardAnimationDurationUserInfoKey]) doubleValue];
	[self.view layoutIfNeeded];
	self.descriptionBottomConstraint.constant = -(keyboardFrame.size.height);
	[UIView animateWithDuration:animationDuration animations:^{
		[self.view layoutIfNeeded];
	}];
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant