UITabBar on top or any other?

怎甘沉沦 提交于 2019-12-11 05:02:16

问题


I'm new to swift, going to create an UI in that a tabor is being shown in it , As i gone through the apple's human interface guidelines , they said not use UITabBar on top. We can use it by custom , but many of them said while submitting in App Store it will get rejected.

So instead of UITabar what should use for the tab on top?


回答1:


You should use a segmented control in the navigation bar, as in this example form the iOS Human Interface Guidelines:

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




回答2:


Is it possible? Sure, but it violates the human interface guidelines.

Swift Version

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.
 }
 */
}


来源:https://stackoverflow.com/questions/39483820/uitabbar-on-top-or-any-other

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!