如何将UISlider更改为垂直? [英] How to Change the UISlider to Vertical?
问题描述
我正在为我的应用定制 UISlider
。我希望滑块处于垂直方向,但默认 UISlider
处于水平方向。我找不到如何更改 UISlider
的方向。
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 couldn't find how to change a UISlider
's orientation.
如何制作垂直滑块XCode? p>
How can I make a vertical slider in XCode?
推荐答案
默认情况下,UISlider是水平的( - )。如果你想使它垂直(|)那么你必须以编程方式执行此操作,可能使用 CGAffineTransform
。例如,您可以将此代码段添加到 viewDidLoad
或您认为合适的任何位置:
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;
这篇关于如何将UISlider更改为垂直?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!