这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions Popping/ButtonViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ @interface ButtonViewController()
@property (nonatomic) UILabel *errorLabel;
@property (nonatomic) FlatButton *button;
@property (nonatomic) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic) NSLayoutConstraint *errorLabelCenterYConstraint;

- (void)addButton;
- (void)addLabel;
Expand Down Expand Up @@ -53,7 +54,7 @@ - (void)addButton
attribute:NSLayoutAttributeCenterX
multiplier:1.f
constant:0.f]];

[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.button
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
Expand Down Expand Up @@ -81,14 +82,15 @@ - (void)addLabel
attribute:NSLayoutAttributeCenterX
multiplier:1
constant:0.f]];

[self.view addConstraint:[NSLayoutConstraint
constraintWithItem:self.errorLabel
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual toItem:self.button
attribute:NSLayoutAttributeCenterY
multiplier:1
constant:0]];

self.errorLabelCenterYConstraint = [NSLayoutConstraint
constraintWithItem:self.errorLabel
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual toItem:self.button
attribute:NSLayoutAttributeCenterY
multiplier:1
constant:0];
[self.view addConstraint:self.errorLabelCenterYConstraint];

self.errorLabel.layer.transform = CATransform3DMakeScale(0.5f, 0.5f, 1.f);
}
Expand Down Expand Up @@ -138,6 +140,9 @@ - (void)showLabel
POPSpringAnimation *layerPositionAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
layerPositionAnimation.toValue = @(self.button.layer.position.y + self.button.intrinsicContentSize.height);
layerPositionAnimation.springBounciness = 12;
[layerPositionAnimation setCompletionBlock:^(POPAnimation *animation, BOOL finished) {
self.errorLabelCenterYConstraint.constant = self.button.intrinsicContentSize.height;
}];
[self.errorLabel.layer pop_addAnimation:layerPositionAnimation forKey:@"layerPositionAnimation"];
}

Expand All @@ -149,6 +154,9 @@ - (void)hideLabel

POPBasicAnimation *layerPositionAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPositionY];
layerPositionAnimation.toValue = @(self.button.layer.position.y);
[layerPositionAnimation setCompletionBlock:^(POPAnimation *animation, BOOL finished) {
self.errorLabelCenterYConstraint.constant = 0.0f;
}];
[self.errorLabel.layer pop_addAnimation:layerPositionAnimation forKey:@"layerPositionAnimation"];
}

Expand Down