简体   繁体   English

iOS版。 我可以在Interface Builder中为UIScrollView制作自定义视图吗?

[英]iOS. Could I made custom view for UIScrollView in Interface Builder?

I have a UIViewController, there is a "static" part in the View, and the scrolling part (UIScrollView). 我有一个UIViewController,视图中有一个“静态”部分,滚动部分(UIScrollView)中有一个。 I know that I must add some View to the UIScrollView. 我知道我必须向UIScrollView添加一些视图。

It's possible to make this View in code only, but I want to make UIView that contains some separated text with different size and colour, for this I will use Labels. 可以仅在代码中创建此View,但是我想使UIView包含一些具有不同大小和颜色的单独文本,为此,我将使用Labels。

It's will a little bigger that a standard fullscreen UIView, so my question is: is it possible to make a UIView that will be bigger than standard iPhone screen in the Xcode, add all what I want from the objects pallet and then use it in the UIScrollView? 一个标准的全屏UIView会更大一点,所以我的问题是:是否可以在Xcode中制作一个比标准iPhone屏幕更大的UIView,将我想要的所有东西添加到对象托盘中,然后在的UIScrollView? If so, how can I do it? 如果是这样,我该怎么办? Thanks. 谢谢。

  1. Make a UIView (self.view) of lets say 320x480 制作一个UIView(self.view)可以说320x480
  2. Add a scrollView in (self.view) of size (320x480) 在(self.view)中添加尺寸为(320x480)的scrollView
  3. Create a new UIView (dataView) of size (320x1200(any height you want)) 创建一个新的UIView(dataView),大小为320x1200(任意高度)
  4. add step3 View(dataView) in the scrollView (step2 view) 在scrollView(step2视图)中添加step3 View(dataView)
  5. set the contentsize of the ScrollView to (320x1200) 将ScrollView的contentsize设置为(320x1200)

becareful set the contentsize to 320x1200 not the scrollView frame size 小心,将contentsize设置为320x1200而不是scrollView框架的大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM