尝试转换。我为你挖出这段代码:
//[self setAnchorPoint:CGPointMake(0.5, 1.0) forView:self.label];
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationCurveEaseInOut
animations:^{
//Scale the height to close to zero
//0.00001, because 0.0 behaves strange
self.label.transform = CGAffineTransformMakeScale(1, 0.00001);
}
completion:^(BOOL finished) {
self.label.hidden = YES;
}];
这会将其缩小到中间。如果你想让它收缩到顶部或底部,你需要设置一个锚点。我也有一些代码:
- (void) setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view {
CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x, view.bounds.size.height * anchorPoint.y);
CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x, view.bounds.size.height * view.layer.anchorPoint.y);
newPoint = CGPointApplyAffineTransform(newPoint, view.transform);
oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform);
CGPoint position = view.layer.position;
position.x -= oldPoint.x;
position.x += newPoint.x;
position.y -= oldPoint.y;
position.y += newPoint.y;
view.layer.position = position;
view.layer.anchorPoint = anchorPoint;
}