SYBlinkAnimationKit 0.3.2

SYBlinkAnimationKit 0.3.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2017年8月
SwiftSwift 版本3.0
SPM支持 SPM

Shohei 维护。



  • 作者
  • Shohei Yokoyama

Awesome

SYBlinkAnimationKit 是一个用于 iOS 的闪烁效果动画框架,用 Swift 编写 :bowtie:

👀演示

为组件有 5 种动画类型。

边界

带阴影的边界

背景

水波纹

文本

:octocat:功能

  • 类似于 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

  • [x] SYCollectionViewCell

即将推出

  • [ ] SYTextView
  • [ ] SYImageView

演示应用

打开 Example/SYBlinkAnimationKit.xcworkspace 并运行 SYBlinkAnimationKit-Example 以查看简单演示。

要运行示例项目,请首先从示例目录运行《pod install》。

🔶用法

首先,在类中导入 SYBlinkAnimationKit

   import SYBlinkAnimationKit

SYBlinkAnimationKit 被设计成易于使用。

  1. 调用 SYClass,例如 SYButtonSYLabelSYTextField、等。
  2. 如果您使用自定义动画,请调用动画方法 startAnimating()stopAnimating()

SYButton

   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()

SYLabel

   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

继承 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

继承 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

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
    }

inspectable

IB 中用整数形式的 animationAdapter 替换 animationType

  • 边界: 0
  • 带阴影的边界: 1
  • 背景: 2
  • 水波纹: 3
  • 文本: 4

动画颜色

您可以自定义颜色属性。这些属性是 inspectable

   var animationBorderColor: UIColor
   var animationBackgroundColor: UIColor
   var animationTextColor: UIColor
   var animationRippleColor: UIColor

动画持续时间、计时

您可以自定义 animationTimingFunctionanimationDuration

   //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 

inspectable

IB 中用整数形式的 animationTimingAdapter 替换 animationTimingFunction

  • 线性: 0
  • 慢进: 1
  • 慢出: 2
  • 先慢进慢出: 3

自定义动画文本

您可以自定义可动画文本的对齐方式。支持 9 种对齐方式。目前 SYButtonSYLabel 支持。

    var textAlignmentMode: TextAlignmentMode
    
    enum TextAlignmentMode {
        case topLeft, topCenter, topRight
        case left, center, right
        case bottomLeft, bottomCenter, bottomRight
    }

是否动画

如果 SYClass 正在进行动画,此属性为 true

   public var isAnimating: Bool

📝要求

  • iOS 8.3+
  • Xcode 8.0+
  • Swift 3.0+

☕️作者

Shohei Yokoyama, [email protected]

🔓许可证

SYBlinkAnimationKit 在 MIT 协议下可用。有关更多信息,请参阅LICENSE 文件