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. Use 0 if 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.Nil if not different from labelFont. 没有选择的按钮的字体,如果为nil的话,就没有区别

  • @property (nonatomic,readonly) NSArray *labels; Access UIView used 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 specify leftTitle and buttons. 初始化方法,你可以用来指定标题以及按钮

  • - (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 a NSString, an UIImageor any UIView (but the view must implement DDExpandableButtonViewSource protocol). 设置左侧view:你可以用字符串,UIImage或者任何UIView

  • - (void)setButtons:(NSArray *)buttons; Set buttons views : you can use a NSString, anUIImage or any UIView (but the view must implement DDExpandableButtonViewSource protocol). 设置buttons,你可以用字符串,UIImage或者任何UIView

  • - (void)disableTimeout; If you want to disable timeout shrunk. You can set timeout to 0 also. 如果你想关闭超时时间,你可以将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的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. java学习-MD5消息摘要算法

    md5 属于hash算法一类,是不可逆的消息摘要算法.与对称加密和非对称加密算法不一样,不需要加密密钥. 注意: md5不是加密算法,只是将数据进行散列计算后生成一个唯一值的算法,没有加密密钥也没有解 ...

  2. NLP Attention

    一.概述 自动摘要可以从很多角度进行分类,例如单文档摘要/多文档摘要.单语言摘要/跨语言摘要等.从技术上说,普遍可以分为三类: i. 抽取式摘要(extractive),直接从原文中抽取一些句子组成摘 ...

  3. elasticsearch(三) 之 elasticsearch目录介绍和配置文件详解

    目录 elasticsearch 配置 目录详情 (config) 配置文件 elasticsearch.yml 配置集群名称(cluster.name) 配置 network.host 更改数据和储 ...

  4. Linux-(diff)

    diff 命令 1.命令格式: diff  [参数]  [文件1或目录1]  [文件2或目录2] 2.命令功能: diff命令能比较单个文件或者目录内容.如果指定比较的是文件,则只有当输入为文本文件时 ...

  5. hadoop学习笔记(六):HDFS文件的读写流程

    一.HDFS读取文件流程: 详解读取流程: Client调用FileSystem.open()方法: 1 FileSystem通过RPC与NN通信,NN返回该文件的部分或全部block列表(含有blo ...

  6. 基于.NET Core2的图片上传

    其实,.NET Core2的图片上传挺好做的,只是,有些坑要注意.......话不多说,上代码 public async Task<IActionResult> Upload([FromS ...

  7. [PHP] 超全局变量$_FILES上传文件

    1.$_FILES --超全局变量,HTTP 文件上传变量 通过 HTTP POST 方式上传到当前脚本的项目的数组,PHP 能够接受任何来自符合 RFC-1867 标准的浏览器上传的文件, 上传的过 ...

  8. 撩课-Web大前端每天5道面试题-Day25

    1.web前端开发,如何提高页面性能优化? 内容方面: .减少 HTTP 请求 (Make Fewer HTTP Requests) .减少 DOM 元素数量 (Reduce the Number o ...

  9. Java数据类型和不同数据类型在JVM内存分配

    1.java数据类型分类 Java语言是强类型(Strongly typed)语言,强类型包含两方面的含义:①所有的变量必须先声明,后使用:②指定类型的变量只能接受类型与之匹配的值.这意味着每个变量和 ...

  10. 商城项目,java返回json数据,报错406

    前言: 项目结构为maven,搭建好架构,整合ssm,进行测试, 从数据库中查询数据,返回json数据,结果报错406 问题: 解决: 1,确定项目中json包是否存在(极大可能出于此) 2,处理器适 ...