A customizable UI element written in Swift that animates a label like it's a news ticker.
✅ Supports UIStoryBoard Interface Builder!
✅ Animates only if text doesn't fit the screen!
✅ Supports both left-to-right and right-to-left texts!
To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift
:
.package(url: "https://github.com/yusif-projects/NewsTickerLabel", .upToNextMajor(from: "1.0.0"))
Then specify "NewsTickerLabel"
as a dependency of the Target in which you wish to use NewsTickerLabel
. Here's an example PackageDescription
:
// 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"])
]
)
- Step 1: Select your project from the project navigator;
- Step 2: Select your project from the project and targets list;
- Step 3: Select package dependencies tab;
- Step 4: Click the
+
button;
- Step 5: Type
https://github.com/yusif-projects/NewsTickerLabel
in the search bar; - Step 6: Select
NewsTickerLabel
from the results list; - Step 7: Select
Up to Next Major Version
from the dependency rules list; - Step 8: Type
1.0.0
in the text field near it; - Step 9: Select your project from the projects list;
- Step 10: Click the
Add Package
button;
- Step 11: Select your target from the targets list;
- Step 12: Click the
Add Package
button.
- Step 13: Right click (or CTRL click) on the
NewsTickerLabel
in the project navigator; - Step 14: Select
Update Package
.
You can find an example project in this repository that demonstrates the usage of NewsTickerLabel
.
Drag and drop a UIView
object from the object library.
In the identity inspector change the class from UIView
to NewsTickerLabel
.
Customize the parameters in the attributes inspector.
Connect the NewsTickerLabel
object to your controller by creating an outlet.
class ViewController: UIViewController {
@IBOutlet weak var newsTickerLabel: NewsTickerLabel!
override func viewDidLoad() {
super.viewDidLoad()
}
}
In the viewDidAppear()
call the activate()
method of your NewsTickerLabel
object.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
newsTickerLabel.activate()
}