Latest 0.1.8
Homepage https://github.com/snowpunch/SwiftyGlyphs
License MIT
Platforms ios 8.0
Authors

Version
License
Platform

Features

  • Dynamically generated character assets.
  • Preserves font color, style and spacing as individual transparent png’s.
  • Option to generate SKSpriteNode glyphs instead for SKActions.

Usage

Animate an array of characters.

alt tag

import UIKit
import SwiftyGlyphs

class ViewController: UIViewController {
   var swiftyLabel = SwiftyGlyphs(fontName: "MarkerFelt-Wide", size:24)

   override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)

      swiftyLabel.text = "SwiftyGlyphs!"
      swiftyLabel.setLocation(self.view, pos: CGPoint(x:0,y:100))
      swiftyLabel.centerTextToView()

      exampleAnimation(swiftyLabel.getGlyphs())
   }

   func exampleAnimation(glyphs:[Glyph]) {
      var delay = 1.0
      for glyph in glyphs {
         UIView.animateWithDuration(0.5, delay: delay, options: [.Repeat, .CurveEaseInOut, .Autoreverse], animations: {
            glyph.imgView.center.y = 140
            glyph.imgView.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI))
         }, completion: nil)
         delay += 0.01
     }
   }
}

SpriteKit Usage

Requres an SKView. With this example I added a UIView the storyboard UIViewController and then customized it in the side panel as an SKView. Then dragged over the IBOutlet.

alt tag

import UIKit
import SpriteKit
import SwiftyGlyphs

class ViewController: UIViewController {

   @IBOutlet weak var skview: SKView!
   var spriteLabel = SpriteGlyphs(fontName: "Copperplate-Light", size:24)

   override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)

      spriteLabel.text = "SpriteKit Baby!!"
      spriteLabel.setLocation(skview, pos: CGPoint(x:0,y:30))
      spriteLabel.centerTextToView()

      spriteKitAnimation(spriteLabel.getSprites())
    }

    func spriteKitAnimation(sprites:[SKSpriteNode]) {

      let moveSeq = SKAction.sequence([
         SKAction.moveBy(CGVector(dx:30,dy:0), duration: 0.3),
         SKAction.moveBy(CGVector(dx:0,dy:30), duration: 0.5),
         SKAction.moveBy(CGVector(dx:-30,dy:0), duration: 0.2),
         SKAction.moveBy(CGVector(dx:0,dy:-30), duration: 0.3),
         SKAction.moveBy(CGVector(dx:0,dy:30), duration: 0.3),
         SKAction.moveBy(CGVector(dx:0,dy:-30), duration: 0.4),
      ])
      moveSeq.timingMode = .EaseIn

      let rotationSeq = SKAction.sequence([
         SKAction.rotateToAngle(CGFloat(M_PI), duration: 1),
         SKAction.rotateToAngle(0, duration: 2.3),
      ])
      rotationSeq.timingFunction = snappyEaseOut

      var delay = 0.0
      for glyphSprite in sprites {
         let delaySeq = SKAction.sequence([Act.waitForDuration(delay),rotationSeq])
         let group = SKAction.group([moveSeq,delaySeq])
         group.timingMode = .EaseInEaseOut
         let repeatAction = SKAction.repeatActionForever(group)
         glyphSprite.runAction(repeatAction)
         delay += 0.01
      }
   }

   func snappyEaseOut (t:Float) -> Float {
      return (t == 1.0) ? t : 1.0 - pow(2.0, -10.0 * t)
   }
}

Installation

SwiftyGlyphs is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SwiftyGlyphs"
Manual Installation (copy 4 files)

SwiftyGlyphs.swift, ImageExtractor.swift, Glyph.swift, SpriteGlyphs.swift

Author & licence

Woodie Dovich, [email protected]

SwiftyGlyphs is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftyGlyphs",
    "version": "0.1.8",
    "summary": "Animate individual characters in a label. SpriteKit optional.",
    "homepage": "https://github.com/snowpunch/SwiftyGlyphs",
    "license": "MIT",
    "authors": {
        "Woodie Dovich": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/snowpunch/SwiftyGlyphs.git",
        "tag": "0.1.8"
    },
    "source_files": "Source/*.swift"
}

Pin It on Pinterest

Share This