测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年8月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Shohei 维护。
SYBlinkAnimationKit 是一个用于 iOS 的闪烁效果动画框架,用 Swift 编写
为组件有 5 种动画类型。
边界
带阴影的边界
背景
水波纹
文本
类似于 UIKit
的闪烁效果动画
5 种动画类型:边界
、带阴影的边界
、背景
、水波纹
、文本
易于使用
可以定制动画的任何属性
[x] 支持 Swift 3.0
[x] 支持 @IBDesignable
和 @IBInspectable
。您可以在 Interface Builder (IB) 检查器中更改属性。然后 IB 会自动更新您的自定义对象。
[x] 兼容 Carthage
[x] SYButton
[x] SYLabel
[x] SYTextField
[x] SYView
[x] SYTableViewCell
即将推出
打开 Example/SYBlinkAnimationKit.xcworkspace
并运行 SYBlinkAnimationKit-Example
以查看简单演示。
要运行示例项目,请首先从示例目录运行《pod install》。
首先,在类中导入 SYBlinkAnimationKit。
import SYBlinkAnimationKit
SYBlinkAnimationKit 被设计成易于使用。
SYButton
、SYLabel
、SYTextField
、等。startAnimating()
、stopAnimating()
let button = SYButton(frame: CGRect(x: 40, y: 50, width: 300, height: 50 ))
button.setTitle("Border Animation", forState: .normal)
button.animationType = .border
view.addSubview(button)
//Run Animation
syButton.startAnimating()
//End Animation
syButton.stopAnimating()
由于可以处理文本,因此提供了 文本动画
如果更改文本字体大小或名称,您应该调用 `setFont()` 方法。
button
.setFont(name: "ArialHebew", ofSize: 21)
.startAnimating()
let label = SYLabel(frame: CGRect(x: 40, y: 50, width: 300, height: 50 ))
label.text = "Text Animation"
label.labelTextColor = .darkGray
label.animationType = .text
view.addSubview(label)
SYLabel
由于可处理文本而支持 文本动画。
如果您要设置文本颜色,您应该设置 labelTextColor
属性。要更改文本字体,使用与 SYButton
相同的字体方法。
label
.setFont(name: "ArialHebew", ofSize: 21)
.startAnimating()
继承 SYTableViewCell
。在 UITableViewDataSource
中自定义您的 TouchableOpacityCell
。
class YourCell: SYTableViewCell {
...
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("YourCell", forIndexPath: indexPath) as! YourCell
cell.animationType = .background
cell.startAnimating()
return cell
}
继承 SYCollectionViewCell
。在 UICollectionViewDataSource
中自定义您的 CollectionViewCell
。
class YourCell: SYCollectionViewCell {
...
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("YourCell", forIndexPath: indexPath) as! YourCell
cell.animationType = .background
cell.startAnimating()
return cell
}
SYTextField 在触摸时停止动画。但您可以控制这种行为。
//The animation stop. when a touch. default is true
syTextField.stopAnimationWithTouch = true
如果您只想更改动画类型,您可以自定义 animationType
。
// default is border
var animationType: AnimationType
// Support 5 types of animation
enum AnimationType: Int {
case border
case borderWithShadow
case background
case ripple
case text
}
在 IB
中用整数形式的 animationAdapter
替换 animationType
。
边界
: 0带阴影的边界
: 1背景
: 2水波纹
: 3文本
: 4您可以自定义颜色属性。这些属性是 inspectable。
var animationBorderColor: UIColor
var animationBackgroundColor: UIColor
var animationTextColor: UIColor
var animationRippleColor: UIColor
您可以自定义 animationTimingFunction
、animationDuration
。
//default is linear
var animationTimingFunction: SYMediaTimingFunction
enum SYMediaTimingFunction: Int {
case linear
case easeIn
case easeOut
case easeInEaseOut
}
//default is 1.5
public var animationDuration: CGFloat
在 IB
中用整数形式的 animationTimingAdapter
替换 animationTimingFunction
。
线性
: 0慢进
: 1慢出
: 2先慢进慢出
: 3您可以自定义可动画文本的对齐方式。支持 9 种对齐方式。目前 SYButton
、SYLabel
支持。
var textAlignmentMode: TextAlignmentMode
enum TextAlignmentMode {
case topLeft, topCenter, topRight
case left, center, right
case bottomLeft, bottomCenter, bottomRight
}
如果 SYClass 正在进行动画,此属性为 true
public var isAnimating: Bool
Shohei Yokoyama, [email protected]
SYBlinkAnimationKit 在 MIT 协议下可用。有关更多信息,请参阅LICENSE 文件。