2015-02-08 3 views
1

Так вот мой Swift код (AppDelegate.swift):UIToolbar смещение - черная полоса, появляющийся

var window: UIWindow? 
var rootViewController :UIViewController? 

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 

    if ((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 7) { 
     //yes, I'm using a newer iOS - greater/equal to iOS 7 
     rootViewController = Login(nibName:"Login",bundle:nil) 
     let x = UIScreen.mainScreen().bounds.size.width 
     let y = UIScreen.mainScreen().bounds.size.height 
     let frame = CGRectMake(0,20,x,y) 
     window = UIWindow(frame: frame) 

     window!.rootViewController = rootViewController 
     window!.makeKeyAndVisible()     

     //window!.frame = CGRectMake(0,20,window!.frame.size.width,window!.frame.size.height-20); 
    } 

    return true 
} 

Я пытаюсь компенсировать экран вниз 20px.

Вот что мой эмулятор выглядит, используя приведенный выше код (неправильно!):

enter image description here

Вот что это выглядит, как если бы я ничего не делаю (так!):

enter image description here

Вот что я хочу, чтобы это выглядело!

enter image description here

Я был на этом в течение нескольких часов.

Я хочу прочный и управляемый способ сдвинуть все на 20 пикселей.

(постскриптум Я не с помощью раскадровки)

ответ

0

Это похоже на работу:

 rootViewController = Login(nibName:"Login",bundle:nil) 

     if ((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8) { 
      //For iOS 8 
      rootViewController?.providesPresentationContextTransitionStyle = true 
      rootViewController?.definesPresentationContext = true; 
      rootViewController?.modalPresentationStyle = UIModalPresentationStyle.CurrentContext 
     }else{ 
      //For iOS 7 
      rootViewController?.modalPresentationStyle = UIModalPresentationStyle.CurrentContext 
     } 
     let x = UIScreen.mainScreen().bounds.size.width 
     let y = UIScreen.mainScreen().bounds.size.height 
     let frame = CGRectMake(0, 0, x, y) 
     window = UIWindow(frame: frame) 
     window!.rootViewController = rootViewController 
     window!.makeKeyAndVisible()