x正在同步, 请稍候查看

GhostTypewriter

 收藏    我在用   0 人在用

一个实现的打字机效果的 Swift 动画效果控件

 GitHub     官网     下载

1    70    8    over 1 year前

Build StatusVersionLicensePlatformCocoaPods

A UILabel subclass that adds a type writing animation effect. The interesting thing about this pod is that the characters will not jump around as they are animated onto the screen instead the characters will be animated onto the screen in their final position - this especially important for multiple line text as the jump can be very visually displeasing.

This pod was inspired by the following post here.

Installation via CocoaPods

To integrate CoreDataServices into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

pod 'GhostTypewriter'

Then, run the following command:

$ pod install

CocoaPods 1.1.1+ is required to build GhostTypewriter.

Usage

TypewriterLabel is a subclass of UILabel and where the animation (magic) happens. It works by taking advantage of the attributedText property on the label and changing the properties of the text content to gradually expose the text using an animation similar to what you get on a mechanical type writer.

Starting

import GhostTypewriter

@IBAction func startAnimationButtonPressed(_ sender: Any) {
    self.descriptionLabel.startTypewritingAnimation(completion: nil)
}

Stoping

import GhostTypewriter

@IBAction func startAnimationButtonPressed(_ sender: Any) {
    if animating {
        descriptionLabel.stopTypewritingAnimation()
    } else {
        self.descriptionLabel.startTypewritingAnimation(completion: nil)
    }
}

Canceling

import GhostTypewriter

@IBAction func startAnimationButtonPressed(_ sender: Any) {
    if animating {
        descriptionLabel.cancelTypewritingAnimation()
    } else {
        self.descriptionLabel.startTypewritingAnimation(completion: nil)
    }
}

Chaining animations

import GhostTypewriter

@IBAction func startAnimationButtonPressed(_ sender: Any) {
    titleLabel.cancelTypewritingAnimation()
    descriptionLabel.cancelTypewritingAnimation()

    titleLabel.startGhostTypewriterAnimation {
        self.descriptionLabel.startTypewritingAnimation(completion: nil)
    }
}

Adjusting animation timing

import GhostTypewriter

override func viewDidLoad() {
    super.viewDidLoad()
    titleLabel.typingTimeInterval = 0.3
}

Storyboards

As TypewriterLabel contained in a pod, when using it in your storyboards you will need to use the Module field with the value GhostTypewriter.

Example

GhostTypewriter comes with an example project to provide more details than listed above.

Found an issue?

Please open a new Issue here if you run into a problem specific to CoreDataServices, have a feature request, or want to share a comment. Note that general Core Data questions should be asked on Stack Overflow.

Pull requests are encouraged and greatly appreciated! Please try to maintain consistency with the existing code style. If you're considering taking on significant changes or additions to the project, please communicate in advance by opening a new Issue. This allows everyone to get onboard with upcoming changes, ensures that changes align with the project's design philosophy, and avoids duplicated work.

No Reply at the moment.
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up