极具动感的 FRDLivelyButton

FRDLivelyButton

https://github.com/sebastienwindal/FRDLivelyButton

FRDLivelyButton is a simple UIButton subclass intended to be used inside a UIBarButtonItem, even though it can be used anywhere you can use a UIButton. It is entirely Core Graphics driven, supports 5 common button types (menu, close, add, etc...) used in navigation bar, and will nicely animate any button type changes and touch events.

FRDLivelyButton 是一个 UIButton 的子类,其设计的目的是用在 UIBarButtonItem 中的,当然呢,它也可以在其他地方当做一个 UIButton 使用。它完全是由 Core Graphics 绘制的,支持5种按钮类型(菜单、关闭、添加等),通常情况下它是用在导航栏上的,而且,在导航栏上,点击这个按钮时会生成一个很好看的动画变化效果。

Requirements

FRDLivelyButton uses ARC and requires iOS 6.1+.

FRDLivelyButton 使用ARC,需要iOS 6.1+

Installation

CocoaPods

pod 'FRDLivelyButton', '~> 1.1.2'

Manual

Copy the folder FRDLivelyButton to your project.

将文件夹 FRDLivelyButton 复制到你的项目中去。

Usage

Add a FRDLivelyButton either in code or using interface builder.

直接使用 FRDLivelyButton 实例化对象或者是用 IB 来实例化。

Example, how to add a FRDLivelyButton in a nav bar:

例如,如何添加 FRDLivelyButton 到导航栏上:

FRDLivelyButton *button = [[FRDLivelyButton alloc] initWithFrame:CGRectMake(0,0,36,28)];
[button setStyle:kFRDLivelyButtonStyleHamburger animated:NO];
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = buttonItem;

To change the button style, just call setStyle:animated:

点击时改变按钮的样式,调用 setStyle:animated: 即可。

[self.myButton setStyle:kFRDLivelyButtonStyleCircleClose animated:YES];

The current type of the button can be accessed using the buttonStyle property:

当前按钮的类型是可以通过属性 buttonStyle 来获取的:

- (IBAction)buttonAction:(FRDLivelyButton *)sender
{
    if (sender.buttonStyle == kFRDLivelyButtonStylePlus) {
        // logic
    } else ....
}

Customizing Appearance

Button appearance and behavior can be customized using an options NSDictionary. Color, highlighted color, line thickness, animation durations, etc... can be customized. Default should work just fine though.

按钮的样式是可以通过字典来定义的。颜色、高亮颜色、线条粗细、动画时长等等,都可以定制,实际上默认值本身就够好了。

See FRDLivelyButton.h for list of possible attributes.

在 FRDLivelyButton.h 文件中查看那些可以修改的属性吧。

Example:

[button setOptions:@{ kFRDLivelyButtonLineWidth: @(2.0f),
                      kFRDLivelyButtonHighlightedColor: [UIColor colorWithRed:0.5 green:0.8 blue:1.0 alpha:1.0],
                      kFRDLivelyButtonColor: [UIColor blueColor]
                      }];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值