Skip to content

TvOSSlider is an implementation of UISlider for tvOS.

License

Notifications You must be signed in to change notification settings

PlasmaSoftUK/TvOSSlider

 
 

Repository files navigation

TvOSSlider

Build Status License MIT Swift 5.0

TvOSSlider is an implementation of UISlider for tvOS.

Description and usage

TvOSSlider palliates missing an implementation of UISlider for tvOS as part of UIKit.

We think that Apple might eventually include UISlider for tvOS as part of UIKit, because of that, and in order to make it easier to migrate to a possible future UIKit component, TvOSSlider has been implemented with the same public API as UISlider for iOS.

The interface only differs in a couple of new properties that were considered needed for a Big Screen implementation:

  • stepValue: Value added or subtracted from the current value as result of Siri Remote click left or right updates.
  • focusScaleFactor: Scale factor applied to the slider when receiving the focus.
import UIKit
import TvOSSlider

class ViewController: UIViewController {

    @IBOutlet private weak var slider: TvOSSlider!
    @IBOutlet private weak var valueLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        slider.addTarget(self, action: #selector(sliderValueChanges), for: .valueChanged)
        slider.minimumValue = 0
        slider.maximumValue = 100
        slider.stepValue = 10
        slider.minimumTrackTintColor = .orange
    }

    @objc
    func sliderValueChanges(slider: TvOSSlider) {
        valueLabel.text = "\(slider.value)"
    }
}

Requirements

  • tvOS 11.0+
  • Xcode 11

Installation

Cocoapods

To integrate TvOSSlider into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :tvos, '11.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'TvOSSlider', :git => 'https://github.com/zattoo/TvOSSlider.git'
end

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate TvOSSlider into your Xcode project using Carthage, specify it in your Cartfile:

github "zattoo/TvOSSlider" ~> 1.2.0

Run carthage update to build the framework and drag the built TvOSSlider.framework into your Xcode project.

Manually

If you prefer, you can also integrate TvOSSlider into your project manually, just copying and linking the framework with your project.

About

TvOSSlider is an implementation of UISlider for tvOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.1%
  • Objective-C 2.1%
  • Ruby 1.8%