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