gpt4 book ai didi

ios - UIToolbar 偏移 - 出现黑条

转载 作者:行者123 更新时间:2023-11-28 09:14:14 30 4
gpt4 key购买 nike

这是我的 Swift 代码 (AppDelegate.swift):

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
}

我试图将屏幕向下偏移 20 像素。

这是我的模拟器使用上面的代码(错误!)的样子:

enter image description here

如果我什么都不做(错误!),这是它的样子:

enter image description here

这就是我想要的样子!

enter image description here

我已经在这里工作了几个小时。

我想要一种稳健且易于管理的方法来将所有内容向下移动 20 像素。

(附注:我使用 Storyboard)

最佳答案

这似乎可行:

        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()

关于ios - UIToolbar 偏移 - 出现黑条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28397202/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com