簡體   English   中英

標簽欄下方的Swift View Layout

[英]Swift View Layout below tabbar

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    self.window?.backgroundColor = UIColor.whiteColor()
    self.window?.makeKeyAndVisible()

    let vc = ViewController()
    vc.tabBarItem = UITabBarItem(...)
    ...
    let tabbar = UITabBarController()
    tabbar.setViewControllers([...,vc,...], animated: false)

    self.window?.rootViewController = tabbar

    tabbar.selectedIndex = 2
    return true
   }
}
class ViewController: UIViewController {
    override func loadView() {
        super.loadView()
        self.view.backgroundColor = UIColor.yellowColor()
        //self.automaticallyAdjustsScrollViewInsets = false;
    }

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

    override func viewDidAppear(animated: Bool) {
         super.viewDidAppear(animated)
  }
}

我沒有使用故事板。

以上導致ViewControllers視圖擴展到選項卡欄下方。 我怎么能阻止這個?

我已經嘗試將視圖框設置為

CGRectMake(0, 0, self.view.frame.width, self.view.frame.height - tabBarController.view.frame.height))

但那沒用。

您可以使用UIViewControlleredgesForExtendedLayout屬性來設置要在導航欄下擴展的邊。 如果你不想要,你可以簡單地說:

self.edgesForExtendedLayout = .None

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM