DEV Community

loading...

Swift で Hello World

dongri profile image D ・1 min read

とりあえずSwiftでHello World書いてみた。
5GBもするXcode 6 betaをダウンロードしてインストール
起動するのに1分ぐらいかかる。

AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    // Override point for customization after application launch.

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

    var label: UILabel = UILabel(frame: CGRectMake(0, 0, 320, 20))
    label.center = CGPointMake(160, 284)
    label.textAlignment = NSTextAlignment.Center
    label.text = "Hello World ! Hello Swift !"
    label.textColor = UIColor.whiteColor()
    controller.view.addSubview(label)
    self.window!.rootViewController = controller

    self.window!.backgroundColor = UIColor.whiteColor()
    self.window!.makeKeyAndVisible()
    return true
}

プロジェクは、github (https://github.com/dongri/swift)

Discussion (0)

pic
Editor guide