簡體   English   中英

動畫“幻燈片”iOS UIView但關聯的子視圖不會移動

[英]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);

任何指針都非常感謝!

UIView和子SubViews沒有動畫

我對Xamarin不太清楚。 但是在objectiveC中,你可以使用,

view.clipsToBounds = YES;

因此,當您嘗試降低高度時,子視圖也會被隱藏。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM