More optimal layoutIfNeeded.
This commit is contained in:
parent
27f6bd7905
commit
d72defb0bc
@ -139,9 +139,7 @@ const long MPAvatarAdd = 10000;
|
||||
|
||||
super.highlighted = highlighted;
|
||||
|
||||
[UIView animateWithDuration:0.1f animations:^{
|
||||
self.avatarImageView.transform = highlighted? CGAffineTransformMakeScale( 1.1f, 1.1f ): CGAffineTransformIdentity;
|
||||
}];
|
||||
self.avatarImageView.transform = highlighted? CGAffineTransformMakeScale( 1.1f, 1.1f ): CGAffineTransformIdentity;
|
||||
}
|
||||
|
||||
- (void)setMode:(MPAvatarMode)mode {
|
||||
@ -168,7 +166,7 @@ const long MPAvatarAdd = 10000;
|
||||
_spinnerActive = spinnerActive;
|
||||
|
||||
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
|
||||
rotate.toValue = [NSNumber numberWithDouble:2 * M_PI];
|
||||
rotate.toValue = @(2 * M_PI);
|
||||
rotate.duration = 5.0;
|
||||
|
||||
if (spinnerActive) {
|
||||
@ -206,10 +204,10 @@ const long MPAvatarAdd = 10000;
|
||||
|
||||
switch (self.mode) {
|
||||
case MPAvatarModeLowered: {
|
||||
[[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height] layoutIfNeeded];
|
||||
[[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height];
|
||||
[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
self.nameContainer.alpha = self.visibility;
|
||||
self.nameContainer.backgroundColor = [UIColor clearColor];
|
||||
self.avatarImageView.alpha = self.visibility / 0.7f + 0.3f;
|
||||
@ -217,10 +215,10 @@ const long MPAvatarAdd = 10000;
|
||||
break;
|
||||
}
|
||||
case MPAvatarModeRaisedButInactive: {
|
||||
[[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height] layoutIfNeeded];
|
||||
[[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height];
|
||||
[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
self.nameContainer.alpha = self.visibility;
|
||||
self.nameContainer.backgroundColor = [UIColor clearColor];
|
||||
self.avatarImageView.alpha = 0;
|
||||
@ -228,10 +226,10 @@ const long MPAvatarAdd = 10000;
|
||||
break;
|
||||
}
|
||||
case MPAvatarModeRaisedAndActive: {
|
||||
[[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height] layoutIfNeeded];
|
||||
[[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height];
|
||||
[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
self.nameContainer.alpha = self.visibility;
|
||||
self.nameContainer.backgroundColor = [UIColor blackColor];
|
||||
self.avatarImageView.alpha = 1;
|
||||
@ -239,10 +237,10 @@ const long MPAvatarAdd = 10000;
|
||||
break;
|
||||
}
|
||||
case MPAvatarModeRaisedAndHidden: {
|
||||
[[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height] layoutIfNeeded];
|
||||
[[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[self.avatarSizeConstraint updateConstant:self.avatarImageView.image.size.height];
|
||||
[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
self.nameContainer.alpha = 0;
|
||||
self.nameContainer.backgroundColor = [UIColor blackColor];
|
||||
self.avatarImageView.alpha = 0;
|
||||
@ -250,10 +248,10 @@ const long MPAvatarAdd = 10000;
|
||||
break;
|
||||
}
|
||||
case MPAvatarModeRaisedAndMinimized: {
|
||||
[[self.avatarSizeConstraint updateConstant:36] layoutIfNeeded];
|
||||
[[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultLow] layoutIfNeeded];
|
||||
[[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[self.avatarSizeConstraint updateConstant:36];
|
||||
[self.avatarRaisedConstraint updatePriority:UILayoutPriorityDefaultLow];
|
||||
[self.avatarToTopConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
[self.nameToCenterConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
self.nameContainer.alpha = 0;
|
||||
self.nameContainer.backgroundColor = [UIColor blackColor];
|
||||
self.avatarImageView.alpha = 1;
|
||||
@ -274,6 +272,8 @@ const long MPAvatarAdd = 10000;
|
||||
self.avatarImageView.backgroundColor = [UIColor clearColor];
|
||||
self.avatarImageView.layer.cornerRadius = self.avatarImageView.bounds.size.height / 2;
|
||||
self.spinner.alpha = self.spinnerActive? 1: 0;
|
||||
|
||||
[self layoutIfNeeded];
|
||||
} completion:nil];
|
||||
}
|
||||
|
||||
|
@ -440,8 +440,9 @@ referenceSizeForHeaderInSection:(NSInteger)section {
|
||||
_active = active;
|
||||
|
||||
[UIView animateWithDuration:animated? 0.4f: 0 animations:^{
|
||||
[[self.navigationBarToTopConstraint updatePriority:active? 1: UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[[self.passwordsToBottomConstraint updatePriority:active? 1: UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[self.navigationBarToTopConstraint updatePriority:active? 1: UILayoutPriorityDefaultHigh];
|
||||
[self.passwordsToBottomConstraint updatePriority:active? 1: UILayoutPriorityDefaultHigh];
|
||||
[self.view layoutIfNeeded];
|
||||
} completion:completion];
|
||||
}
|
||||
|
||||
|
@ -786,7 +786,7 @@ typedef NS_ENUM(NSUInteger, MPActiveUserState) {
|
||||
// Manage the entry container depending on whether a user is activate or not.
|
||||
switch (activeUserState) {
|
||||
case MPActiveUserStateNone: {
|
||||
[[self.navigationBarToTopConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[self.navigationBarToTopConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
self.avatarCollectionView.scrollEnabled = YES;
|
||||
self.entryContainer.alpha = 0;
|
||||
self.footerContainer.alpha = 1;
|
||||
@ -796,7 +796,7 @@ typedef NS_ENUM(NSUInteger, MPActiveUserState) {
|
||||
case MPActiveUserStateUserName:
|
||||
case MPActiveUserStateMasterPasswordChoice:
|
||||
case MPActiveUserStateMasterPasswordConfirmation: {
|
||||
[[self.navigationBarToTopConstraint updatePriority:UILayoutPriorityDefaultHigh] layoutIfNeeded];
|
||||
[self.navigationBarToTopConstraint updatePriority:UILayoutPriorityDefaultHigh];
|
||||
self.avatarCollectionView.scrollEnabled = NO;
|
||||
self.entryContainer.alpha = 1;
|
||||
self.footerContainer.alpha = 1;
|
||||
@ -804,13 +804,15 @@ typedef NS_ENUM(NSUInteger, MPActiveUserState) {
|
||||
break;
|
||||
}
|
||||
case MPActiveUserStateMinimized: {
|
||||
[[self.navigationBarToTopConstraint updatePriority:1] layoutIfNeeded];
|
||||
[self.navigationBarToTopConstraint updatePriority:1];
|
||||
self.avatarCollectionView.scrollEnabled = NO;
|
||||
self.entryContainer.alpha = 0;
|
||||
self.footerContainer.alpha = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self.view layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
[_afterUpdates setSuspended:NO];
|
||||
}];
|
||||
|
Loading…
Reference in New Issue
Block a user