一个可自定义的 UI 元素,可像新闻自动收报机一样对标签进行动画处理

跟随 星 iOS 13.0+ 斯威夫特 5.5+ 许可证

新闻自动收报机标签

一个用 Swift 编写的可自定义的 UI 元素,它像新闻自动收报机一样为标签设置动画。

✅ 支持UIStoryBoard界面生成器!

✅ 仅当文本不适合屏幕时才制作动画!

✅ 支持从左到右和从右到左的文本!

🚚 安装

要使用 Apple 的 Swift 包管理器进行集成,请将以下内容作为依赖项添加到您的:Package.swift

.package(url: "https://github.com/yusif-projects/NewsTickerLabel", .upToNextMajor(from: "1.0.0"))

然后指定为要使用的目标的依赖项。下面是一个例子:"NewsTickerLabel"NewsTickerLabelPackageDescription

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    name: "MyPackage",

    products: [
        .library(name: "MyPackage", targets: ["MyPackage"])
    ],

    dependencies: [
        .package(url: "https://github.com/yusif-projects/NewsTickerLabel", .upToNextMajor(from: "1.0.0"))
    ],

    targets: [
        .target(name: "MyPackage", dependencies: ["NewsTickerLabel"])
    ]
)

🏗 Usage

You can find an example project in this repository that demonstrates the usage of .NewsTickerLabel

Example using UIStoryBoard Interface Builder:

Drag and drop a object from the object library.UIView

In the identity inspector change the class from to .UIViewNewsTickerLabel

Customize the parameters in the attributes inspector.

Connect the object to your controller by creating an outlet.NewsTickerLabel

class ViewController: UIViewController {
    
    @IBOutlet weak var newsTickerLabel: NewsTickerLabel!

    override func viewDidLoad() {
        super.viewDidLoad()
    }

}

In the call the method of your object.viewDidAppear()activate()NewsTickerLabel

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

    newsTickerLabel.activate()
}

📝 License

GNU GPLv3

GitHub

点击跳转