與變換嘗試。我爲你挖出這個代碼:
//[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;
}
你想要/你期望的文本,而其高度變化? – 2012-07-12 19:00:46
是你想要動畫的高度還是位置? – trumpetlicks 2012-07-12 19:00:48