Reputation: 93
I have viewController with slider inside and I need to change the position of slider programmatically. I am using following code:
mySliderOutlet.frame = CGRectMake(100, 250, mySliderOutlet.frame.size.width, mySliderOutlet.frame.size.height)
Problem is this doesn't do anything. Outlet is connected correctly, I am using it elsewhere in the code to read values from slider. I will be glad for any suggestions. Thanks.
Upvotes: 1
Views: 1322
Reputation: 20804
With AffineTransform
you can rotate your UISlider
layer
try this code for this results
class ViewController: UIViewController {
@IBOutlet weak var verticalSlider: UISlider!
func DEGTORAD(deg:Double) -> CGFloat
{
return CGFloat(deg * M_PI / 180.0)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
verticalSlider.layer.setAffineTransform(CGAffineTransformMakeRotation(DEGTORAD(90)))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I hope this helps you
Upvotes: 0
Reputation: 8011
Please make sure, following this are done before setting the frames on your slider
Upvotes: 2