WWTypewriterLabel

main

Mimics the display function of a typewriter.
William-Weng/WWTypewriterLabel

WWTypewriterLabel

Swift-5.6 iOS-14.0 TAG Swift Package Manager-SUCCESS LICENSE

  • Mimics the display function of a typewriter.
  • 模仿打字機的顯示功能。

WWTypewriterLabel

dependencies: [
    .package(url: "https://github.com/William-Weng/WWTypewriterLabel.git", .upToNextMajor(from: "1.0.0"))
]

Function - 可用函式

函式 功能
start(fps:stringType:loopType:) 開始打字機顯示功能
stop(isShowFull:) 停止打字機顯示功能

Example - 程式範例

import UIKit
import WWPrint
import WWTypewriterLabel

final class ViewController: UIViewController {

    @IBOutlet weak var typewriterLabel: WWTypewriterLabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        typewriterTest()
    }
    
    func typewriterTest() {
        
        let string = "A typewriter is a mechanical or electromechanical machine for typing characters. Typically, a typewriter has an array of keys, and each one causes a different single character to be produced on paper by striking an inked ribbon selectively against the paper with a type element. At the end of the nineteenth century, the term 'typewriter' was also applied to a person who used such a device."
        
        let formattedText = NSAttributedString(string: string, attributes: [
            .font: UIFont.systemFont(ofSize: 20),
            .foregroundColor: UIColor.blue
        ])
        
        typewriterLabel.start(fps: 60, stringType: .general(string), loopType: .once)

        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
            self.typewriterLabel.start(fps: 30, stringType: .attributed(formattedText), loopType: .infinity)
        }
    }
}

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Oct 21 2024 07:27:59 GMT-0900 (Hawaii-Aleutian Daylight Time)