我有一个UIButton
地方在我看来。在按钮的触摸事件中,我UIView
出现了。UIAnimation
我使用的使视图从窗口顶部显示。但我希望它出现在 button.frame.origin.y 中。在触摸按钮之前,视图是不可见的。触摸按钮视图应从上方位置开始出现。
这是代码:
-(IBAction) ShowInfowView:(id)sender{
CGRect rect = viewInfo.frame;
rect.origin.y = rect.size.height - rect.size.height+58.0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
viewInfo.frame = rect;
[UIView commitAnimations];
}
这就是我再次隐藏视图的方式:
-(IBAction) HideInfoView:(id)sender{
CGRect rect = viewInfo.frame;
rect.origin.y = -rect.size.height;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
viewInfo.frame = rect;
[UIView commitAnimations];
}
在 viewDidLoad 我正在做以下事情:
CGRect rect = viewInfo.frame;
rect.origin.y = -rect.size.height;
viewInfo.frame = rect;
更新:
请看这个例子。这里的视图是从屏幕顶部出现的。我希望它从按钮 y 轴出现。就此而言,请考虑将按钮 y 位置向上一点。