Skip to content

πŸ“ŠΒ A customizable UI element that animates a label like it's a news ticker.

License

Notifications You must be signed in to change notification settings

yusif-projects/NewsTickerLabel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

54 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Follow Star iOS 13.0+ Swift 5.5+ License

NewsTickerLabel

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!

Table of contents

🚚 Installation

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"])
    ]
)

Or you can use Xcode's built-in tools:

  • 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.

How to get the latest update:

  • Step 13: Right click (or CTRL click) on the NewsTickerLabel in the project navigator;
  • Step 14: Select Update Package.

πŸ— 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 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()
}

πŸ“ License

Apache