Skip to content
This repository was archived by the owner on Aug 24, 2019. It is now read-only.
This repository was 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

@TimAEllis

Description

@TimAEllis

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];
	}];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions