[翻译] 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];

 

目录
相关文章
|
XML Java Android开发
[翻译]IAdaptable是什么?
IAdaptable在Eclipse里是一个非常重要的接口。对于Eclipse开发老手来说,它就像异常处理和抽象类一样寻常;但是对新手而言,它却令人感到困惑和畏惧。这篇文章将向你解释IAdaptable到底是什么,以及它在Eclipse里起到的作用。
1177 0
|
iOS开发 Android开发