How to Change the UISlider to Vertical?

前端 未结 3 1381
既然无缘
既然无缘 2021-02-07 01:04

I am customizing an UISlider for my app. I want the slider to be in vertical orientation, but the default UISlider is in horizontal orientation. I coul

3条回答
  •  离开以前
    2021-02-07 01:40

    By default, a UISlider is horizontal (--). If you wish to make it vertical (|) then you must do this programmatically, probably with a CGAffineTransform. For example, you can add this snippet to viewDidLoad or wherever you deem appropriate:

    CGAffineTransform trans = CGAffineTransformMakeRotation(M_PI_2);
    slider.transform = trans;
    

提交回复
热议问题