gpt4 book ai didi

ios - 如何创建 Airbnb iOS App Explore 选项卡?

转载 作者:搜寻专家 更新时间:2023-10-31 22:57:39 24 4
gpt4 key购买 nike

airbnb full airbnb full


我正在尝试创建一个类似于 Airbnb 应用程序屏幕截图的提要页面。我从 UITableViewController 开始,并在滚动时向标题添加了动画;标题是那里的绿松石色区域。

现在我想添加这些页面选项卡(“为您推荐”、“家庭”、“体验”和“地点”),并且弄不清楚我应该如何构建我的 View 。仅供引用,每个选项卡都是一个 tableView。现在我没有页面选项卡的结构是:

  1. UITabBarController
  2. UIViewController(包含UIView header ,UITableView 内容)

我能想到的选项很少:

  1. 每个页面标签都是一个UITableViewDataSource,所以点击一个标签只是改变了dataSourcereloadData()
  2. UIViewController 将包含一个 UIScrollView contentView,因此单击选项卡是 addSubView 到 contentView 和 addChildViewController 到控制者

根据我的研究,不推荐选项 #2,因为它将 tableView 放在 scrollView 中。但是选项 #1 要求所有 tableView 具有相同的 cellID 才能出队?听起来硬编码。请告诉我这种情况的最佳做法!谢谢。

最佳答案

根据您的描述,您可能应该考虑使用容器 View 。通过这种方式,您将对所描述的每个案例都有单独的 View 。

给你的例子:

在 Storyboard中:

enter image description here

听到的是切换 View 的代码。

class ViewController: UIViewController {
@IBOutlet weak var containerViewA: UIView!
@IBOutlet weak var containerViewB: UIView!

override func viewDidLoad() {
super.viewDidLoad()
}

@IBAction func showComponent(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 0 {
UIView.animate(withDuration: 0.5, animations: {
self.containerViewA.alpha = 1
self.containerViewB.alpha = 0
})
} else {
UIView.animate(withDuration: 0.5, animations: {
self.containerViewA.alpha = 0
self.containerViewB.alpha = 1
})
}
}
}

关于ios - 如何创建 Airbnb iOS App Explore 选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42899815/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com