iOS伸缩式菜单 [英] iOS Retractable Menu

查看:88
本文介绍了iOS伸缩式菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个包含音乐播放器的应用程序.截至目前,它具有播放,暂停和&选择歌曲按钮,显示当前正在播放的歌曲.现在,播放器始终在屏幕上.我要这样做,以便在页面中间有一个按钮,以便当用户单击该按钮时,将出现带有播放,暂停和选择歌曲按钮/图标的整个媒体播放器.当他们再次单击该中间按钮时,它将隐藏这些图标.

I am currently developing an app that contains a music player. As of now it has a play, pause, & a select song button that shows the current song playing. Right now, the player is always on the screen. I want to make it so theres a button in the middle of the page so that when users click that, the whole media player with the play, pause, and select song button/icon will appear. When they click on that middle button again it shall hide those icons.

如果有人可以指出正确的方向,无论是已经发布的教程,还是其他很棒的讨论(我真的找不到任何讨论)!

If anybody could point me in the right direction whether it be tutorials already out, or other discussions (I could not find any ones really) that would be awesome!

注意:我不是要制作Facebook使用的弹出菜单.此菜单/音频播放器将在当前视图上水平扩展/收缩

NOTE: I'm not trying to make the popover menu that facebook uses. This menu/audio player will expand/retract horizontally over the current view

预先感谢您!!!!

推荐答案

我不确定您要寻找的视觉效果是什么,但我想您已经说过了-只需隐藏它们即可.

I'm not exactly sure what visual effect your looking for, but I think you already said it - just hide them.

您可以通过以下两种方式进行操作.

You can do that a couple of ways.

一种简单的方法就是将这些元素放入自己的视图中.使用情节提要或Xib文件.在视图中放置要隐藏的按钮和控件.

One simple way is just to put those elements inside of their own view. Use a storyboard or xib file. Put your buttons and controls you want to hide show in a view.

然后在您的视图控制器中创建对该视图的引用.称之为controlsView.

Then create a reference in your view controller to that view. call it controlsView.

 @property (strong,nonatomic) IBOutlet UIView *controlsView;

确保您连接了该视图.

然后,当按下按钮时,只需隐藏整个视图即可:

Then when the button is pushed, just hide that entire view:

 self.controlsView.hidden = YES;

再次按下时,显示它:

 self.controlsView.hidden = NO;

如果您想要更平滑的外观和感觉,请将其包裹在这样的动画中:

If you want a bit smoother look and feel, wrap it in an animation like this:

  //to hide
  [UIView animateWithDuration:2 animations:^{
       [self.controlsView setAlpha:0];
  } completion {
       self.controlsView.hidden = YES;
  }];

  //to show
  self.controlsView.alpha = 0;
  self.controlsView.hidden = NO;
  [UIView animateWithDuration:2 animations:^{
       [self.controlsView setAlpha:1.0];
  } completion {

  }];

希望有帮助

这篇关于iOS伸缩式菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆