lufthansa747 lufthansa747 - 1 year ago 81
Swift Question

Swift View Layout bellow 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()

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() {
self.view.backgroundColor = UIColor.yellowColor()
//self.automaticallyAdjustsScrollViewInsets = false;

override func viewDidLoad() {

override func viewDidAppear(animated: Bool) {

I am not using a story board.

The above causes the ViewControllers view to extend bellow the tab bar. How can i stop this?

Ive tried setting the views frame to

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

but that did not work

Answer Source

You can use the edgesForExtendedLayout property of UIViewController to set which edges to extend under navigation bars. If you don't want any, you can simply say:

self.edgesForExtendedLayout = .None
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download