ios - UIScrollView 添加顶部空白

标签 ios swift uiscrollview insets

我使用 swift 以编程方式创建了一个 ScrollView 我在其中添加了一个 UIView 将这两个添加到 view 后,它会在 ScrollView 顶部显示 Empty Space 我怎样才能删除它,我在谷歌中搜索并找到了几个并尝试了它们

self.edgesForExtendedLayout = UIRectEdge.None;
self.extendedLayoutIncludesOpaqueBars = true;
self.automaticallyAdjustsScrollViewInsets = false;

let insets = UIEdgeInsetsMake(self.topLayoutGuide.length, 0.0, self.bottomLayoutGuide.length, 0.0);
scrollContainer.contentInset = insets;

请推荐

最佳答案

问题是由导航栏和底部标签栏引起的。 所以你的插图应该是这样的:

let insets = UIEdgeInsetsMake(0, 0.0, 0.0, 0.0);

如果您使用 Storyboard和自动布局,则需要遵循以下设置:

enter image description here

关于ios - UIScrollView 添加顶部空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34452254/

相关文章:

android - 网站和移动应用程序数据库链接

iOS条件链接静态库

iphone - 在 Xcode 中使按钮链接到不同的 ViewController

ios - 如何在 UIAlertviewController 中激活“确定”按钮?

iphone - UIImage 从 UIImageView 流出

swift 4 : nil loading local UIImage

arrays - Swift 3.1 : Array too large to be initialized?(程序卡住)

ios - 具有继承的类可编码

ios - 计算 UIScrollView 的内容大小

iphone - 将 NSString 拆分为 UITextField 页面