Ios:swift Interface Example 1, simple interface

Source: Internet
Author: User

Apple has launched a new language based on Objective-c Swift. By example, we can feel the new language very well.

Note: In the Xcode6_beta, if there is Chinese, the IDE's auto-completion function will be invalid, so start debugging can be used in English, followed by Chinese instead.

1. New iOS, single View application.

2. Modify the Appdelegate.swift file

1 //2 //Appdelegate.swift3 //Uibycode_swift_1_helloworld4 //5 //Created by Yao_yu on 14-6-18.6 //Copyright (c) yao_yu. All rights reserved.7 //8 9 Import UIKitTen  One @UIApplicationMain A classAppdelegate:uiresponder, uiapplicationdelegate { -                              -var Window:uiwindow? the  -  -Func application (application:uiapplication, Didfinishlaunchingwithoptions launchoptions:nsdictionary?)Bool { -Self.window =UIWindow (Frame:UIScreen.mainScreen (). Bounds) +         //Override point for customization after application launch. -let window = self.window! +Window.backgroundcolor =Uicolor.whitecolor () A window.makekeyandvisible () at          -Let frame =Uiscreen.mainscreen (). Bounds -Let edge:cgfloat = - -          -var Labelhello = UILabel (Frame:cgrectmake (EDGE, (Frame.height-edge)/2, Frame.width-edge *2, EDGE)) -Labelhello.textalignment =Nstextalignment.center inLabelhello.text ="Hello, Welcome to Swift World!"     //after adding Chinese, Xcode's auto-complete function will not come out. - Window.addsubview (Labelhello) to          +         return true -     } the  * func applicationwillresignactive (application:uiapplication) { $         //Sent when the application are about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US Er quits the application and it begins the transition to the background state.Panax Notoginseng         //Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. -     } the  + func Applicationdidenterbackground (application:uiapplication) { A         //Use the method to release the shared resources, save user data, invalidate timers, and store enough application state in Formation to the restore your application to the it is terminated later. the         //If Your application supports background execution, this method is called instead of Applicationwillterminate:when th E user quits. +     } -  $ func Applicationwillenterforeground (application:uiapplication) { $         //Called as part of the transition from the background to the inactive state; Here you can undo many of the changes mad E on entering the background. -     } -  the func applicationdidbecomeactive (application:uiapplication) { -         //Restart Any tasks this were paused (or not yet started) while the application is inactive. If the application is previously in the background, optionally refresh the user interface.Wuyi     } the  - func applicationwillterminate (application:uiapplication) { Wu         //Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:. -     } About  $  -}

3. Running

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.