【问题标题】:UITabBar on top or any other?UITabBar 在顶部还是其他?
【发布时间】:2016-09-14 06:30:22
【问题描述】:

我是 swift 新手,要创建一个 UI,其中显示了一个 tabor,因为我浏览了 苹果的人机界面指南,他们说不要在上面使用 UITabBar。我们可以自定义使用,但是很多人说在App Store提交时会被拒绝。

那么顶部的标签应该使用什么来代替 UITabar?

【问题讨论】:

  • 您可以创建一个包含按钮的视图并将该视图放在顶部。您可以根据您的 UI 要求自定义视图和按钮。

标签: ios swift uitabbarcontroller uitabbar


【解决方案1】:

您应该在导航栏中使用分段控件,如本示例中的 iOS 人机界面指南:

https://developer.apple.com/ios/human-interface-guidelines/ui-controls/segmented-controls/

【讨论】:

    【解决方案2】:

    有可能吗?当然可以,但它违反了人机界面准则。

    斯威夫特版本

    import UIKit
    
    class TabViewController: UITabBarController, UITabBarControllerDelegate {
    
    override func viewDidLoad() {
      super.viewDidLoad()
      self.delegate = self
      // Do any additional setup after loading the view.
    }
    override func viewWillLayoutSubviews() {
     super.viewWillLayoutSubviews()
     self.tabBar.invalidateIntrinsicContentSize()
     var tabSize: CGFloat = 44.0
     let orientation = UIApplication.sharedApplication().statusBarOrientation
     if UIInterfaceOrientationIsLandscape(orientation)
     {
        tabSize = 32.0;
     }
     var tabFrame = self.tabBar.frame
     tabFrame.size.height = tabSize
     tabFrame.origin.y = self.view.frame.origin.y
     self.tabBar.frame = tabFrame
     self.tabBar.translucent = false
     self.tabBar.translucent = true
    }
      override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
    }
     /*
     // MARK: - Navigation
    
     // In a storyboard-based application, you will often want to do a little preparation before navigation
      override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
     }
     */
    }
    

    【讨论】:

      猜你喜欢
      • 2017-07-12
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 1970-01-01
      • 2011-05-19
      相关资源
      最近更新 更多