[翻译] DDExpandableButton
DDExpandableButton

https://github.com/ddebin/DDExpandableButton
Purpose - 目的
DDExpandableButton is a single-file iOS 5.0+ non-ARC class (ARC compatible) designed to be used like an expandable UIButton ; as seen in the iOS Camera app for the flash button.
DDExpandableButton 是一个MRC的类(兼容ARC),用来点击时展开UIButton;与iOS照相机应用的flash按钮一样。
Originally inspired by ExpandyButton.

Properties - 属性
A DDExpandableButton has the following properties:
有以下属性列表:
@property (nonatomic,assign) BOOL expanded;Current button status (if expanded or shrunk). 当前按钮的状态(展开了还是未展开)@property (nonatomic,assign) BOOL useAnimation;Use animation during button state transitions. 在button状态改变时是否使用动画效果@property (nonatomic,assign) BOOL toggleMode;Use button as a toggle (like "HDR On" / "HDR Off" button in camera app). 是否用作开关(像照相机应用中的“HDR On / HDR Off”按钮一样)@property (nonatomic,assign) CGFloat timeout;To shrink the button after a timeout. Use0if you want to disable timeout. 一个未展开的超时时间,用0可以禁用超时时间@property (nonatomic,assign) CGFloat horizontalPadding;Horizontal padding space between items. 按钮间的水平距离@property (nonatomic,assign) CGFloat verticalPadding;Vertical padding space above and below items. 按钮间的垂直距离@property (nonatomic,assign) CGFloat borderWidth;Width (thickness) of the button border. 按钮边缘的厚度@property (nonatomic,assign) CGFloat innerBorderWidth;Width (thickness) of the inner borders between items. 按钮内边缘的厚度@property (nonatomic,assign) NSUInteger selectedItem;Selected item number. 选择的第几个@property (nonatomic,retain) UIColor *borderColor;Color of the button and inner borders. 按钮内边缘颜色@property (nonatomic,retain) UIColor *textColor;Color of text labels. 文本的颜色@property (nonatomic,retain) UIFont *labelFont;Font of text labels. 文本的字体@property (nonatomic,retain) UIFont *unSelectedLabelFont;Font of unselected text labels.Nilif not different fromlabelFont. 没有选择的按钮的字体,如果为nil的话,就没有区别@property (nonatomic,readonly) NSArray *labels;AccessUIViewused to draw labels. 所有label
Methods - 方法
A DDExpandableButton has the following methods:
DDExpandableButton 有着如下的一些方法:
- (id)initWithPoint:(CGPoint)point leftTitle:(id)leftTitle buttons:(NSArray *)buttons;Init method where you can specifyleftTitleandbuttons. 初始化方法,你可以用来指定标题以及按钮- (void)setSelectedItem:(NSUInteger)selected animated:(BOOL)animated;Animated version of- (void)setSelectedItem:(NSUInteger)selected. 这个方法- (void)setSelectedItem:(NSUInteger)selected的动画版本- (void)setExpanded:(BOOL)expanded animated:(BOOL)animated;Animated version of- (void)setExpanded:(BOOL)expanded. 这个方法- (void)setExpanded:(BOOL)expanded的动画版本- (void)setLeftTitle:(id)leftTitle;Set left title view : you can use aNSString, anUIImageor anyUIView(but the view must implementDDExpandableButtonViewSourceprotocol). 设置左侧view:你可以用字符串,UIImage或者任何UIView- (void)setButtons:(NSArray *)buttons;Set buttons views : you can use aNSString, anUIImageor anyUIView(but the view must implementDDExpandableButtonViewSourceprotocol). 设置buttons,你可以用字符串,UIImage或者任何UIView- (void)disableTimeout;If you want to disable timeout shrunk. You can settimeoutto0also. 如果你想关闭超时时间,你可以将timeout设置成0- (void)updateDisplay;When modifying button parameters, use this method to update button display. 但编辑按钮的参数时,你需要用这个方法来更新按钮的显示
Protocols - 协议
The DDExpandableButtonViewSource protocol, used when you specify the title or the different buttons, has the following methods:
DDExpandableButtonViewSource 协议,当你在制定标题或者不同的按钮时,有着如下的一些方法:
- (CGSize)defaultFrameSize;Returns default frame size of the view, used when expanding the button. 展开按钮的时候返回view的默认尺寸- (void)setHighlighted:(BOOL)highlighted;Optional, used to change appearance of selected items. 可选的,用来修改选中按钮的外观
Usage - 使用
Example : a button with four text labels and a hook when value change.
NSArray *buttons = [NSArray arrayWithObjects:@"Black", @"Red", @"Green", @"Blue", nil];
DDExpandableButton *colorButton = [[[DDExpandableButton alloc] initWithPoint:CGPointMake(20, 70) leftTitle:@"Color" buttons:buttons] autorelease];
[[self view] addSubview:colorButton];
[colorButton addTarget:self action:@selector(toggleColor:) forControlEvents:UIControlEventValueChanged];
[翻译] DDExpandableButton的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- shell:syntax error:unexpected end of file/Starting proxy www-balancer: cannot bind socket--转载
src:http://www.2cto.com/os/201308/238962.html 执行某bash脚本是发生: syntax error: unexpected end of file 主 ...
- [codeup] 1126 看电视
题目描述 暑假到了,小明终于可以开心的看电视了.但是小明喜欢的节目太多了,他希望尽量多的看到完整的节目. 现在他把他喜欢的电视节目的转播时间表给你,你能帮他合理安排吗? 输入 输入包含多组测试数据.每 ...
- 从Qt到PyQt
Hello World PyQt与Qt具有极其相似的类族和API,而且不再使用qmake系统和Q_OBJECT宏使得PyQt在没有编译链接时频繁的错误而且代码更加友好. from PyQt4 impo ...
- 什么是SOA
面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立于实现服务的硬件平台.操作系统和编 ...
- Java多线程学习之synchronized总结
0.概述 synchronized是Java提供的内置的锁机制,来实现代对码块的同步访问,称为内置锁(Intrinsic Lock) .内置锁包括两部分:一个是作为锁的对象的引用,另一个是由这个锁保护 ...
- 二十一、curator recipes之TreeCache
简介 curator的TreeCache允许对某个路径的数据和路径变更以及其下所有子孙节点的数据和路径变更进行监听. 官方文档:http://curator.apache.org/curator-re ...
- java利器------反射机制
java反射的概念:java的反射机制是指在运行状态下,对于一个类来说,可以得到这个类的所有方法和属性.对于一个对象来说,可以调用这个对象的人和方法和属性. 反射机制首先会拿到该类的字节码文件(Cla ...
- 软件架构系列二:Clean架构
外圈的层次可以依赖内层,反之不可以:内圈核心的实体代表业务,不可以依赖其所处的技术环境. 这是著名软件大师Bob大叔提出的一种架构,也是当前各种语言开发架构.干净架构提出了一种单向依赖关系,从而在逻辑 ...
- grafana 安装- 曲线图展示每秒新增数据量
下载: https://dl.grafana.com/oss/release/grafana-5.4.2.windows-amd64.zip 解压就能用 添加数据源 添加查询条件 sql 模式编写查询 ...
- 简单的PHP的任务队列
文章太长,不作过多介绍,反正,文章的头部就说明了大概的意思...原文如下:写了一个简单的队列任务处理.多进程任务,异步任务可能会用到这个(主要是命令行应用)比如,任务的某个一个环节速度十分不稳定,可能 ...