Simplify the scroll down button layout.

pull/2/head
Matthew Chen 6 years ago
parent 4a7c2e97b7
commit 0e87d2e5b3

@ -2595,7 +2595,7 @@ typedef enum : NSUInteger {
{ {
CGFloat inset = -(self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length); CGFloat inset = -(self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length);
self.scrollDownButtonButtomConstraint.constant = inset; self.scrollDownButtonButtomConstraint.constant = inset;
[self.view setNeedsLayout]; [self.scrollDownButton setNeedsLayout];
} }
- (void)setHasUnreadMessages:(BOOL)hasUnreadMessages - (void)setHasUnreadMessages:(BOOL)hasUnreadMessages
@ -3886,16 +3886,14 @@ typedef enum : NSUInteger {
// RADAR: #36297652 // RADAR: #36297652
[self updateScrollDownButtonLayout]; [self updateScrollDownButtonLayout];
[self.scrollDownButton setNeedsLayout];
[self.scrollDownButton layoutIfNeeded];
// HACK: I've made the assumption that we are already in the context of an animation, in which case the // HACK: I've made the assumption that we are already in the context of an animation, in which case the
// above should be sufficient to smoothly move the scrollDown button in step with the keyboard presentation // above should be sufficient to smoothly move the scrollDown button in step with the keyboard presentation
// animation. Yet, setting the constraint doesn't animate the movement of the button - it "jumps" to it's final // animation. Yet, setting the constraint doesn't animate the movement of the button - it "jumps" to it's final
// position. So here we manually lay out the scroll down button frame (seemingly redundantly), which allows it // position. So here we manually lay out the scroll down button frame (seemingly redundantly), which allows it
// to be smoothly animated. // to be smoothly animated.
CGRect newButtonFrame = self.scrollDownButton.frame; CGRect newButtonFrame = self.scrollDownButton.frame;
newButtonFrame.origin.y newButtonFrame.origin.y = self.scrollDownButton.superview.height
= self.scrollDownButton.superview.height - (newInsets.bottom + self.scrollDownButton.height); - (newInsets.bottom + self.scrollDownButton.height + self.bottomLayoutGuide.length);
self.scrollDownButton.frame = newButtonFrame; self.scrollDownButton.frame = newButtonFrame;
// Adjust content offset to prevent the presented keyboard from obscuring content. // Adjust content offset to prevent the presented keyboard from obscuring content.

Loading…
Cancel
Save