Visually arrange subviews in a large UIScrollView

后端 未结 2 509
-上瘾入骨i
-上瘾入骨i 2020-12-16 00:43

One of the screens in my app has to be vertically scrollable. Its contents is more or less static, but it doesn\'t fit on the phone\'s screen (hence the scroll view). I\'m u

相关标签:
2条回答
  • 2020-12-16 01:31

    It's possible finally in Xcode 11!
    Select some view inside your scroll view in the View Tree and then scroll with your touchpad/mouse:

    0 讨论(0)
  • 2020-12-16 01:33

    There is another way to do it that is different from the answers given in the link in the comment above which I believe is easier because it allows you to see your whole content view at full size and design it in Storyboard.

    • 1)Place a UIScrollView as the root view of the controller.
    • 2) Click on the View Controller in storyboard and goto the Attribute Inspector and change the Size to Freeform
    • 3) Click on the Scroll View in storyboard and goto the Size Inspector and change the Width & Height to as big as you need. (2,000 x 4,000)
    • 4)Place a UIView as a subview of the scrollview, this will be your Content View where you will design your screen and put all your subviews. Don't forget to set the contentSize of the scrollview to the size of this view in viewDidLoad.
    • 5) Click on the UIView from #4 and in the Size Inspector set the Struts and Springs so this view is not resized enter image description here.
    • 6) Design the rest of the screen

    The trick is in #3 & #5 setting the size of the scrollView to really large so you can design. When this viewController is loaded into the iPhone the Struts & Springs will resize the scrollView to the size of the iPhone screen, but the contentView will stay large.

    0 讨论(0)
提交回复
热议问题