你只是在改變框架的高度。這將保持相同的x和y原點值。
你需要從零高度至循環改變高度和原點,像htis ...
[UIView animateWithDuration:60
animations:^{
CGRect frame = left.frame;
// adjust size of frame to desired value
frame.size.height -= 0.1;
frame.origin.y += 0.1; // make opposite to origin as to height
left.frame = frame; // set frame on your view to the adjusted size
}
completion:^(BOOL finished){
// Re-start the animation if desired
}];
100高度(例如)
- (void)animateHeight
{
[UIView animateWithDuration:60
delay:0.0
options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat
animations:^{
CGRect frame = left.frame;
// adjust size of frame to desired value
frame.size.height = 100;
frame.origin.y -= 100; // make opposite to origin as to height
left.frame = frame; // set frame on your view to the adjusted size
}
completion:^(BOOL finished){
// animation is auto reversing and repeating.
}];
}
接受的答案。 – Fogmeister