如果您有想要触发的事件,然后在后面运行动画,这是一件非常简单的事情。
- (void)myEventMethod:(id)sender {
// Do your event stuff here
// Animate the pink box into view
// The below assumes the pink box is hidden behind the blackView and you'd like to drop it down 44 pixels over 0.3 seconds - hopefully correct - haven't tested
// need to be careful as it'll move down 44px every time myEventMethod: is triggered
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
CGRect pinkboxEndFrame = CGRectMake(self.blackView.frame.origin.x, self.blackView.frame.origin.y + 44, self.pinkbox.frame.size.width, self.pinkbox.frame.size.height);
[self.pinkbox setFrame:pinkboxEndFrame];
}
completion:nil];
}
只需使用您想要对其他视图执行的任何其他动画来更新上述内容。
有关动画视图的更多信息,您可以查看 Apple 的View Programming Guide。