FaveButtonSwift 2.1.7

FaveButtonSwift 2.1.7

Ampilogov Vitaly 维护。



  • 作者:
  • Jansel Valentin

FaveButton

CocoaPods CocoaPods Carthage compatible codebeat badge Build Status

Swift 编写的收藏动画按钮

preview

要求

  • iOS 8.0+
  • Xcode 7.3

安装

对于手动安装,请将资源文件夹拖到您的项目中。

os 使用 CocoaPod,请将以下行添加到您的 Podfile

pod 'FaveButton', '~> 1.2.1' swift 2.2

pod 'FaveButton', '~> 2.0.3' swift 3

对于 Carthage 用户,请将以下行添加到您的 Cartfile

github "xhamr/fave-button"

使用方法

使用 Storyboard 或 Xib 文件

  1. 创建一个继承自 FaveButton 的按钮

  2. Normal 状态添加图片

  3. IBOutlet 委托属性设置为 FaveButtonDelegate 的子类

  4. 可选 修改属性以更改按钮设置

@IBInspectable public var normalColor:     UIColor
@IBInspectable public var selectedColor:   UIColor
@IBInspectable public var dotFirstColor:   UIColor
@IBInspectable public var dotSecondColor:  UIColor
@IBInspectable public var circleFromColor: UIColor
@IBInspectable public var circleToColor:   UIColor
  1. 可选 响应委托方法
func faveButton(faveButton: FaveButton, didSelected selected: Bool)    
func faveButtonDotColors(faveButton: FaveButton) -> [DotColors]?     

在代码中

let faveButton = FaveButton(
    frame: CGRect(x:200, y:200, width: 44, height: 44),
    faveIconNormal: UIImage(named: "heart")
)
faveButton.delegate = self
view.addSubview(faveButton)

操作点颜色

如果您想要像Twitter的爱心动画一样使用不同颜色显示点,可以使用您想要的按钮的委托方法。

func faveButtonDotColors(_ faveButton: FaveButton) -> [DotColors]?{
	if faveButton == myFaveButton{
		// return dot colors
	}
	return nil
}

FaveButtonDemo中,您会找到一组颜色,使点呈现如下效果

preview

致谢

FaveButton受到了Twitter在其AppDimitris KoutsogiorgasDanielle LancashireEric AmordeOrta TheroxPaul BeusterienSamuel Giddins,以及CocoaPods 开发团队的启发,他们的贡献来自很多人

许可协议

FaveButton遵循MIT许可协议发布。