[英]Animating a 'Slide' iOS UIView but associated SubViews don't move
我遇到的问题是我认为是UINavigationBar的简单UIView幻灯片动画。 我有一个带有UIButton的UIView,我想通过设置View高度来模拟导航栏中的向下滑动效果。 问题是查看动画,但任何子视图,例如UIButton保持固定。
我在Xamarin(C#)编码,但我确信它很简单,可以阅读Objective-C编码器
if (_menuView == null)
{
// set initial frame
_menuView = new MenuView{Frame = Window.Frame};
// store original "expanded" height for later
_expandedMenuHeight = _menuView.Frame.Height;
// set the frame to underneath the NavigationBar
var frame = ((UINavigationController)Window.RootViewController).NavigationBar.Frame;
var y = frame.Bottom;
// Add to Window View
menuView.Frame = new RectangleF(_menuView.Frame.X,y,_menuView.Frame.Width,0);
Window.Add(_menuView);
}
// Toggle View Height - if collapsed, expand, if expanded, collapse
var height = _menuView.Frame.Height == 0 ? _expandedMenuHeight : 0;
// Animate the height
UIView.Transition (_menuView,0.2,UIViewAnimationOptions.CurveEaseIn | UIViewAnimationOptions.LayoutSubviews,() => {
_menuView.Frame = new RectangleF(0,_menuView.Frame.Y,_menuView.Frame.Width,height); },null);
任何指针都非常感谢!
我对Xamarin不太清楚。 但是在objectiveC中,你可以使用,
view.clipsToBounds = YES;
因此,当您尝试降低高度时,子视图也会被隐藏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.