I'll definately have to update this gif, it doesn't look that crappy anymore!
initialRenderer(closure: (UIView, UIView?, SwiftTickerView, CGFloat) -> Void)
positon your node view wherever you want them to be placedupdateRenderer(closure: (UIView, CGFloat) -> Void)
use this to customize your rendering option for e.g. to fade in the items or fade outbottomToTopStopAtCenter(holdForSeconds seconds: TimeInterval)
this can be used to create the mostly in TV used Ticker where the Ticker node appears at the bottom, when reaching center stayes there for some time and continues to the top
- Add support for iOS 9
- Fixes ignoreSeparator on startup when calling reloadData #5
- Fix center vertical and horizontal
```Renderer.topToBottom.customize(with: SwiftTickerItemDecorators.prepareAtBottomInnerBorder(with: 8))```
* ```prepareAtTopInnerBorder()```
* ```prepareAtTopOuterBorder()```
* ```prepareAtBottomInnerBorder()```
* ```prepareAtBottomOuterBorder()```
* ```prepareAtLeftInnerBorder()```
* ```prepareAtLeftOuterBorder()```
* ```prepareAtRightInnerBorder()```
* ```prepareAtRightOuterBorder()```
Implement your own inital or update Render decorator by implementing the InitialRenderer & SwiftTickerItemDecorator
or UpdateRenderer & SwiftTickerItemDecorator
ignoreFirstSeparator
Add a decorator to the TickerView by callingtickerView.add(.ignoreFirstSeparator)
SwiftTickerView.Renderer.rightToLeft
renamed toRenderer.rightToLeft
SwiftTickerView.Renderer.leftToRight
renamed toRenderer.leftToRight
SwiftTickerView.Renderer.topToBottom
renamed toRenderer.topToBottom
SwiftTickerView.Renderer.bottomToTop
renamed toRenderer.bottomToTop
- You can now implement your own renderer
- renamed
direction
torenderer
Direction.horizontalRightToLeft
renamed toSwiftTickerView.Renderer.rightToLeft
Direction.horizontalLeftToRight
renamed toSwiftTickerView.Renderer.leftToRight
Direction.verticalTopToBottom
renamed toSwiftTickerView.Renderer.topToBottom
Direction.verticalBottomToTop
renamed toSwiftTickerView.Renderer.bottomToTop
- Now supports TV OS
- Performance improvements
To run the example project, clone the repo, and run pod install
from the Example directory first.
SwiftTickerView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftTickerView'
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.renderer = SwiftTickerView.Renderer.rightToLeft
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
}
}
Martin Eberl, [email protected]
SwiftTickerView is available under the MIT license. See the LICENSE file for more info.