DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

D
D

Posted on

Swift ใง Hello World

ใจใ‚Šใ‚ใˆใš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
}
Enter fullscreen mode Exit fullscreen mode

ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใฏใ€github (https://github.com/dongri/swift)

Top comments (0)

๐ŸŒ™ Dark Mode?!

ย 
Turn it on in Settings