FaveButton 3.2.1

FaveButton 3.2.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最新发布2019年12月
SPM支持 SPM

Jansel Valentin 维护。



  • By
  • Jansel Valentin

FaveButton

CocoaPods CocoaPods Carthage compatible codebeat badge Build Status Swift 4.2

用 Swift 编写的喜爱的动画按钮

preview

要求

  • iOS 8.0+
  • Xcode 9+

安装

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

os 使用 CocoaPod 将此行添加到您自己的 Podfile

pod 'FaveButton'

对于 Carthage 用户,将此行添加到您的 Cartfile

github "xhamr/fave-button"

使用

带有故事板或 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在其应用中使用的“赞”心形动画的启发

许可

FaveButton遵循MIT许可。