[翻译] BTSimpleRippleButton

简介:

BTSimpleRippleButton

https://github.com/balram3429/btSimpleRippleButton

This is a custom button for iOS with Ripple effect. It is simple to integrate & customizable component. Suppors callback using blocks.

这是一个自定义的button,带有波纹效果.这是一个很容易使用并定制的组件,支持block回调.

Requirements

  • Xcode 5 or higher Xcode 5以及以上
  • Apple LLVM compiler Apple LLVM 编译器
  • iOS 7.1 or higher iOS 7.1 及以上
  • ARC ARC

Demo

Build and run the BTSimpleRippleButton project in Xcode to see BTRippleButtton in action.

编译以及运行这个demo项目来看看效果.

Installation

  1. Drag the file btRippleButtton.h / btRippleButtton.m to your project. Alternatively you can add the folder btRippleButton to your project. 将btRippleButtton.(h/m)文件拖入到你的项目当中
  2. Maken an import statement for the file as #import"BTRippleButtton.h" . 引入头文件
  3. Add to your project the QuartzCore framework make an import statement for it. 添加QuartzCore framework框架

Initialization

To go with a simple initialization, use the below method. Provide an image, frame size, the target method & the sender view.

你可以进行简易的初始化,使用以下的方法,提供一张 image, frame size,以及目标

BTRippleButtton *rippleButton = [[BTRippleButtton alloc]initWithImage:[UIImage imageNamed:@"pin.png"]
                                                             andFrame:CGRectMake(144, 55, 32, 32)
                                                            andTarget:@selector(buttonTapped:)
                                                                andID:self];

[rippleButton setRippeEffectEnabled:YES];
[rippleButton setRippleEffectWithColor:[UIColor colorWithRed:240/255.f green:159/255.f blue:10/255.f alpha:1]];
[self.view addSubview:rippleButton];

Block based call back

For block based initialization to enable call back, use the below simple method.

基于block方式的回调,使用以下方法

BTRippleButtton *rippleButtonGreen = [[BTRippleButtton alloc] initWithImage:[UIImage imageNamed:@"author.png"] andFrame:CGRectMake(110, 300, 99, 99) onCompletion:^(BOOL success) { // add here more code to block NSLog(@"I am from Block, execution."); }]; [rippleButtonGreen setRippeEffectEnabled:YES]; [rippleButtonGreen setRippleEffectWithColor:[UIColor colorWithRed:204/255.f green:270/255.f blue:12/255.f alpha:1]]; [self.view addSubview:rippleButtonGreen];

 

目录
相关文章
|
9月前
|
并行计算 算法 程序员
FreeLearning C/C++ 译文集翻译完成
FreeLearning C/C++ 译文集翻译完成
38 1
|
存储 自然语言处理 前端开发
从零写一个Recoil(翻译)
Rewriting Recoil from scratchrecoil是facebook编写的一个库,它之所以诞生是因为人体工程学、context的性能问题和useState。这是一个非常聪明的库,几乎每个人都会找到它的用途——如果你想了解更多,请查看这段解释视频。刚开始我被图论和recoil惊到了,但渐渐的理解后,感觉也没那么特别了。也许我也可以实现一个类似的东西。我自己实现的版本和recoil
253 0
从零写一个Recoil(翻译)
|
开发工具 iOS开发 MacOS
|
存储 Swift iOS开发