【问题标题】:How to make a stretchable tableView header in swift 4?如何在 swift 4 中制作可拉伸的 tableView 标题?
【发布时间】:2019-01-09 19:26:16
【问题描述】:

]

您好,我上传了两张图片。最初,我的屏幕看起来像 First Image。如果用户向上滚动屏幕,则屏幕将看起来像第二张图片。我在 GitHub 和互联网上搜索了一个可拉伸的标题。我找到了一个以编程方式生成视图的解决方案。但是出于设计目的,我无法在该特定视图中加载更多两个视图。如果我加载自定义 UI 视图,它会在此函数中显示错误 ->

func scrollViewDidScroll(_ scrollView: UIScrollView) {
 let y = 300 - (scrollView.contentOffset.y + 300)
    let height = min(max(y, 60), 400)
    //imageView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: height)
    myNewView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: height)


}

非常感谢您的帮助

【问题讨论】:

    标签: ios xcode uitableview tableview swift4


    【解决方案1】:

    您可以参考 GitHub 库。 这里有一些链接。

    1. UITableView 和 UICollectionView 的通用伸缩标题

    https://github.com/gskbyte/GSKStretchyHeaderView

    2.UIScrollView 的通用伸缩标题,允许您动态更改导航栏的外观。

    https://github.com/sunlubo/StretchyHeaderView

    3.您可以使用在 medium.com 上找到的一篇文章

    https://medium.freecodecamp.org/tutorial-creating-stretchy-layouts-on-ios-using-auto-layout-3fa974fa5e28

    我通过使用它对 CustomUIView 做了同样的事情。

    https://github.com/maxep/MXSegmentedPager

    【讨论】:

    • 感谢您的回复女士,我已经查看了所有这些链接。但无法做到这一点。基本上最大的例子是使用 imageView。我需要一个 UIView。特别是 CustomUIView。
    猜你喜欢
    • 1970-01-01
    • 2022-08-17
    • 2011-08-30
    • 1970-01-01
    • 2015-01-22
    • 2019-04-17
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    相关资源
    最近更新 更多