Vertical UISlider in iOS with autolayout

后端 未结 10 1885
难免孤独
难免孤独 2021-02-07 07:22

As per my iPad app requirement, i\'ve to show the UISlider vertically.
I\'m using iOS7 compiler and deployment target is iOS6.
In the story board I added horizontal UISl

10条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 07:35

    I got a vertical slider working with iOS 8 and Xcode 6 with only 3 constraints in the storyboard and one line of code. Here's a cropped screencap of the interface:

    enter image description here

    There are 3 constraints between the vertical slider and the UIImageView next to it:

    1. vSlider.Center Y = Image View.Center Y
    2. vSlider.Width = Image View.Height
    3. vSlider.Center X = Image View.Trailing + 16

    And of course the one line of code is:

    self.vSlider.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi / 2))
    

    It's easy to set up these constraints in the storyboard in Xcode 6, but I think it should be simple to write these constraints in code to support iOS 7 or 6.

提交回复
热议问题