Latest 1.0.0
Homepage https://github.com/EMart86/SwiftTickerView
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Animation

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

SwiftTickerView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SwiftTickerView'

Setup

You can eigther embed the SwiftTickerView within an Storyboard or a Xib View, or instantiate the View just like any other view:

let tickerView = SwiftTickerView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 30))

Use the separator property to simply create those textual separators or set a separator view class or nib to create those separator views. Also implement the viewProvider protocol to manipulate the separator view and the node view on demand

tickerView.separator = "+++"
tickerView.viewProvider = self
...

Register also some custom node views to be able to load them more easily

tickerView.registerNodeView(UILabel.self, for: labelIdentifier)

If you want some callbacks on if the user stopped the ticker view (yes, the user can stop the view by tapping on the ticker view), implement the tickerDelegate and don’t forget to asign it to the ticker view. You will also be able to determine the content, which the user has selected.

tickerView.tickerDelegate = self

This ticker view is designed to be able to support arabic and hebrew aswell as the other languages. Simply use the direction property, to determine if you want the content to run from left to right, from right to left, from top to bottom or from bottom to top:

tickerView.direction = .horizontalRightToLeft

You can manage the velocity of the content to run across the display. You can alter this value at runtime aswell to increase or slow down the ticker view:

tickerView.pixelPerSecond = 60 //default is 60

Don’t forget to start the tickerview, otherwhise it’s not working:

tickerView.start() 

And last but not least, implement the contentProvider property to provide your content!

Btw, in the viewProvider protocol, the view node view creation function has to return a tuple with a view parameter and an optional reuseIdentifier parameter. Use this parameter to store it and reuse it for later usage:

func tickerView(_ tickerView: SwiftTickerView, viewFor: Any) -> (UIView, reuseIdentifier: String?) {
    if let text = viewFor as? String,
        let label = tickerView.dequeReusableNodeView(for: labelIdentifier) as? UILabel {
        label.text = text
        label.sizeToFit()
        label.textColor = .white
        return (label, reuseIdentifier: labelIdentifier)
    }
    return (UIView(), reuseIdentifier: nil)
}

func tickerView(_ tickerView: SwiftTickerView, prepareSeparator separator: UIView) {
    if let separator = separator as? UILabel {
        separator.textColor = .white
    }
}

Author

Martin Eberl, [email protected]

License

SwiftTickerView is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftTickerView",
    "version": "1.0.0",
    "summary": "A simple news ticker view",
    "description": "A swift ticker, written in swift. The one, with those '+++' separators ;)",
    "homepage": "https://github.com/EMart86/SwiftTickerView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Martin Eberl": "[email protected]"
    },
    "source": {
        "git": "https://github.com/EMart86/SwiftTickerView.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftTickerView/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This