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
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))
}
}
}