How to Change the UISlider to Vertical?

前端 未结 3 1378
既然无缘
既然无缘 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:37

    I had a problem with :

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

    because I had the code in ViewDidLoad method. Instead, I put the code in ViewDidAppear and it worked fine.

    Edit: it doesn't have to be in the ViewDidAppear, ViewDidLoad works fine too (even better). You could disable auto-resize, or set a constraint for the slider you're rotating so the size doesn't change after rotation.

提交回复
热议问题