基于Swift的应用程序是否适用于OS X 10.9 / iOS 7及更低版本? [英] Do Swift-based applications work on OS X 10.9/iOS 7 and lower?

查看:114
本文介绍了基于Swift的应用程序是否适用于OS X 10.9 / iOS 7及更低版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于Swift的应用程序是否适用于 OS X 10.9 (Mavericks)/ iOS  7和更低?

Will Swift-based applications work on OS X 10.9 (Mavericks)/iOS 7 and lower?

例如,我有一台运行的机器OS X 10.8 (Mountain Lion),我想知道我在Swift中编写的应用程序是否会运行它。

For example, I have a machine running OS X 10.8 (Mountain Lion), and I am wondering if an application I write in Swift will run on it.

推荐答案

我刚刚为你测试过,Swift应用程序编译成标准二进制文件,可以在OS X 10.9和iOS 7上运行。

I just tested it for you, Swift applications compile into standard binaries and can be run on OS X 10.9 and iOS 7.

用于测试的简单Swift应用程序:

Simple Swift application used for testing:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    var controller = UIViewController()
    var view = UIView(frame: CGRectMake(0, 0, 320, 568))
    view.backgroundColor = UIColor.redColor()
    controller.view = view

    var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
    label.center = CGPointMake(160, 284)
    label.textAlignment = NSTextAlignment.Center
    label.text = "I'am a test label"
    controller.view.addSubview(label)

    self.window!.rootViewController = controller
    self.window!.makeKeyAndVisible()
    return true
}

这篇关于基于Swift的应用程序是否适用于OS X 10.9 / iOS 7及更低版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆