Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a vertical slider in swift?

I was wondering how I can create a vertical slider in swift.

I have tried using .transform and then adding a rotate but this returned an exception and rotated the whole screen. I just need a vertical slider.

I was wondering if anyone know of a way to rotate a slider in swift?

Thanks

like image 950
cross Avatar asked Apr 19 '15 15:04

cross


1 Answers

Assuming you are talking about UISlider :

You were looking in a right direction but probably applied AffineTransformation to the wrong item... You should use UISlider.transform to change it orientation. Here is working code (I did add UISlider using InterfaceBuilder):

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var verticalSlider: UISlider!{
        didSet{
            verticalSlider.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI_2))
        }
    }
}
like image 182
CryingHippo Avatar answered Sep 23 '22 13:09

CryingHippo