SweetLike
演示
需求
- iOS 10.0+
- Xcode 11.0+
- Swift 5.0+
安装
SweetLike 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'SweetLike'
使用
创建,
在故事板
@IBOutlet weak var sweetLikeButton: SweetLike!
或编程方式
let sweetLikeButton = SweetLike()
获取点赞和取消点赞动作,
有完成回调
sweetLikeButton.likeAction = {}
sweetLikeButton.unlikeAction = {}
通过代理(SweetLikeDelegate)
func likeAction() {}
func unlikeAction() {}
有一些属性您可以更改
属性 | 描述 | 类型 | 默认值 |
---|---|---|---|
IBInspectable likedImage | 点赞时显示的图片 | UIImage | 命名:likedAsset |
IBInspectable unlikedImage | 未点赞时显示的图片 | UIImage | 命名:unlikedAsset |
IBInspectable likedColor | 默认点赞图片的颜色 | UIColor | UIColor(red: 201/255, green: 97/255, blue: 80/255, alpha: 1) |
IBInspectable unlikedColor | 默认未点赞图片的颜色 | UIColor | UIColor(red: 201/255, green: 97/255, blue: 80/255, alpha: 1) |
likeActionAnimationDuration | 点赞动画的持续时间 | Double | 0.6 |
unlikeActionAnimationDuration | 点取消赞动画的持续时间 | Double | 0.15 |
isAnimationEnabled | 表示动画是否启用或禁用的布尔值 | Bool | true |
作者
Yusuf Demirci, [email protected]
许可证
SweetLike 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。