Giter Club home page Giter Club logo

tvosslider's Introduction

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.

tvosslider's People

Contributors

cgoldsby avatar dcordero avatar milosmokic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tvosslider's Issues

Can not scrub through the Slider

I am creating the TVOSSlider programatically when added Min, Max values with stepValue, slider is only working when I tap left and right of the siri remote. It is not working to scrub over the slider.

Issues when setting an initial Value other than 0

This control works reasonably well, thank you for the time you put in to it. When using this control I want to set an initial value which I do with:

let slider = TvOSSlider(frame: CGRect(x: 100 y: 100, width: 1000, height: 50))
slider.minimumValue = 0
slider.maximumValue = 255
slider.value = 50
view.addSubview(slider)

The control takes this value, and when you read it back it returns 50, however the visual slider in the UI remains at 0. When you start to move it, the control resets its value to 0 and starts incrementing from there. Would be great if this could display the correct initial value.

Using Left or Right Click on latest Apple TV remote doesn't work

Trying to alter the value with the latest Apple TV remote when using click instead of swipe doesn't work.
The control wobbles like it received input but its not possible to alter the value using this method.
As a side effect this breaks the control for 3rd Party IR remotes which also use the old style Presses with .leftArrow and .rightArrow.

setValue for TvOSSlider

hello,
please i'm trying to set value for the tvosslider programmatically on viewDidLoad
like this
slider.setValue(50.0, animated: true)
but the slider not moving it stay at 0
please help

thank you

Slider stepValue doesn't seem to be recognised

When setting stepValue to 1 it is impossible to make the interface increase by just one, seems to step by around 10 increments.
Maybe this could be tied in to issue #16 and when using the click buttons only step up or down by one multiple of the step value?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.