zoukankan      html  css  js  c++  java
  • [翻译] 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. 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];
    

  • 相关阅读:
    Linux服务器上监控网络带宽命令
    boost编译很慢的解决方法
    python select poll
    python SocketServer
    boost implicit_cast
    函数名 函数名取地址 区别
    STL make_heap push_heap pop_heap sort_heap
    STL: fill,fill_n,generate,generate_n
    gcc __attribute__
    Linux命令 lsof使用
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3984968.html
Copyright © 2011-2022 走看看