I'm having a problem with what I thought was a simple UIView slide animation from a UINavigationBar. I have a UIView with a UIButton and I would like to simulate a slide down/up effect from the Navigation Bar by animating the View height. The problem is the View animates but any SubViews eg UIButton stay fixed.
I'm coding in Xamarin (C#) but I'm sure it's simple enough to read for Objective-C coders
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);
Any pointers are greatly appreciated!
I am not so clear with Xamarin. But in objectiveC, you could use,
view.clipsToBounds = YES;
So when you are trying to reduce the height the subviews would also be hidden.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.