UPStackMenu 1.0.0

UPStackMenu 1.0.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发行上次发行2015年2月

Paul Ulric 维护。



  • 作者:
  • Paul Ulric

UPStackMenu 是一个采用堆叠布局的菜单,可以通过一些特效动画展开和折叠。

demo

需求

UPStackMenu 使用 ARC,并且需要 iOS 7.0 或更高版本。

适用于 iPhone。

安装

手动安装

只需将文件夹 UPStackMenu 复制到您的项目中,并在 XCode 中导入。

使用方法

首先导入头文件

#import "UPStackMenu.h"

现在,您可以通过提供一个内容视图来创建一个 UPStackMenu 对象。

UPStackMenu *stack = [[UPStackMenu alloc] initWithContentView:aView];

然后,您可以创建一些将成为堆叠一部分的项目。

UPStackMenuItem *item = [[UPStackMenuItem alloc] initWithImage:anImage highlightedImage:anImage title:aTitle];

最后,将这些项目添加到堆叠菜单中。

[stack addItems:@[item]];

代理

代理是可选的,当某些事件发生时将得到通知

  • - (void)stackMenuWillOpen:(UPStackMenu*)menu
  • - (void)stackMenuDidOpen:(UPStackMenu*)menu
  • - (void)stackMenuWillClose:(UPStackMenu*)menu
  • - (void)stackMenuDidClose:(UPStackMenu*)menu
  • - (void)stackMenu:(UPStackMenu*)menu didTouchItem:(UPStackMenuItem*)item atIndex:(NSUInteger)index

方法

方法 描述
addItem:(UPStackMenuItem*)item 将单个条目添加到堆栈中
addItems:(NSArray*)items 将多个条目添加到堆栈中
removeItem:(UPStackMenuItem*)item 从堆栈中删除特定的条目
removeItemAtIndex:(NSUInteger)index 从堆栈中删除单个条目,对应到索引
removeAllItems 删除所有堆叠条目
items 返回一个包含所有堆叠条目的数组
openStack 编程方式请堆叠打开并显示其项目
closeStack 编程方式关闭堆叠并隐藏其项目

自定义

UPStackMenu

堆叠菜单可以通过许多属性来自定义。

stackPosition 属性将确定堆叠条目的位置,相对于堆叠菜单视图

  • UPStackMenuStackPosition_up - 条目位于堆叠菜单视图上方(默认值)
  • UPStackMenuStackPosition_down - 条目位于堆叠菜单视图下方

在选择栈打开和关闭时的动画效果时,您可以选择三种动画效果,就像在演示GIF中看到的那样。

  • UPStackMenuAnimationType_linear - 如演示2(默认)所示
  • UPStackMenuAnimationType_progressive - 如演示1所示
  • UPStackMenuAnimationType_progressiveInverse - 如演示3所示

其他可定制的栈属性如下:

  • itemsSpacing - 每个栈菜单项目之间的垂直间距,以像素为单位(默认值是6)
  • bouncingAnimation - 是否在打开动画结束时或关闭动画开始时项目会弹跳(默认值为YES)
  • openAnimationDuration - 打开动画的总持续时间,以秒为单位(默认值为0.4)
  • closeAnimationDuration - 关闭动画的总持续时间,以秒为单位(默认值为0.4)
  • openAnimationDurationOffset - 打开过程中每个项目动画开始之间的延迟,以秒为单位(默认值为0)
  • closeAnimationDurationOffset - 关闭过程中每个项目动画开始之间的延迟,以秒为单位(默认值为0)

UPStackMenuItem

您可以通过labelPosition属性在每项的标题位置之间选择两个位置。

  • UPStackMenuItemLabelPosition_left - 标题将位于图标左侧(默认)
  • UPStackMenuItemLabelPosition_right - 标题将位于图标右侧

如果您想选择项目标题的字体,必须通过特定的构造函数来实现

- (id)initWithImage:(UIImage*)image highlightedImage:(UIImage*)highlightedImage title:(NSString*)title font:(UIFont*)font

标题颜色也可以通过以下方法进行自定义:

- (void)setTitleColor:(UIColor*)color

许可协议

The MIT License (MIT)

Copyright (c) 2015 Paul Ulric

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.