问题
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