Start Xcode6 from Launchpad and select "Create New Project":
650) this.width=650; "class=" Alignnone wp-image-548 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06/new _project.png "alt=" New_project "width=" 529 "height=" "style=" margin:5px 20px 20px 0px;padding:0px;border:0px; Font-family:inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height: Inherit;vertical-align:middle;height:auto; "/>
As you can see, the Swift language project is basically the same as the OBJECTIVE-C project, except.m
The end of the objective-c source is replaced by.swift
The end of the swift language source file.
650) this.width=650; "class=" Alignnone wp-image-549 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06/ Source_file.png "alt=" source_file "width=" 346 "height=" 331 "style=" margin:5px 20px 20px 0px;padding:0px;border:0px; Font-family:inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height: Inherit;vertical-align:middle;height:auto; "/>
2. Xcode 6 Adds a unified interface management function to the ipad and iphone in storyboard, working with Autolayou. For the sake of simplicity, disable AutoLayout first.
650) this.width=650; "class=" Alignnone wp-image-550 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06 /size_class.png "alt=" Size_class "width=" "height=" 214 "style=" margin:5px 20px 20px 0px;padding:0px;border:0px; Font-family:inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height: Inherit;vertical-align:middle;height:auto; "/>
When you disable AutoLayout, the dialog box pops up to choose whether it's iphone or ipad, and we choose to develop the iphone app.
650) this.width=650; "class=" Alignnone wp-image-551 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06 /layout.png "alt=" layout "width=" 383 "height=" 213 "style=" margin:5px 20px 20px 0px;padding:0px;border:0px;font-family : Inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit; Vertical-align:middle;height:auto; "/>
3. From the control bar, hold down the left mouse button and drag into a label
tag, double-click the control to add text, you can modify the text color, font, alignment, etc. in the property bar on the right:
650) this.width=650; class= alignnone wp-image-552 "src=" Http://blog.diveinedu.net/wp-content/uploads/2014/06/label.png "alt=" label "width=" 439 "height=" 388 "style=" margin : 5px 20px 20px 0px;padding:0px;border:0px;font-family:inherit;font-size:inherit;font-style:inherit;font-variant: Inherit;font-weight:inherit;line-height:inherit;vertical-align:middle;height:auto; "/>
4. Click the Run button in the upper left corner of Xcode to build and run the program.
650) this.width=650; "class=" Alignnone wp-image-553 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06 /run.png "alt=" Run "width=" 537 "height=" 656 "style=" margin:5px 20px 20px 0px;padding:0px;border:0px;font-family: Inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit; Vertical-align:middle;height:auto; "/>
The Run button is the Stop button and you can close the application.
5. In order to get this tag object in the code, we need to connect to the storyboard and the corresponding controller class. It is easiest to start the auxiliary editor directly to connect.
650) this.width=650; "class=" Alignnone wp-image-554 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06/ Associate_editor.png "alt=" Associate_editor "width=" 610 "height=" 324 "style=" margin:5px 20px 20px 0px;padding:0px; Border:0px;font-family:inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit; Line-height:inherit;vertical-align:middle;height:auto; "/>
6. Xcode will automaticallyViewController
Generated inIBOutlet
Properties of adornmentslabel
。
ViewController.swift// SwiftApp_1//// Copyright (c) 2014 Changsha Camp David Education . all rights reserved.//import uikitclass viewcontroller: Uiviewcontroller { //xcode automatically generated properties that can be seen in storyboard after @iboutlet decoration @IBOutlet var label : uilabel override func viewdidload () { super.viewdidload () //Modifying the contents of a label label in code self.label.text = "Camp David Education welcomes you! " } override func didreceivememorywarning () { super.didreceivememorywarning () // dispose of any resources that can be recreated. }}
7. The running results of the program are as follows:
650) this.width=650; "class=" Alignnone wp-image-555 "src=" http://blog.diveinedu.net/wp-content/uploads/2014/06/ First_result.png "alt=" First_result "width=" 514 "height=" 786 "style=" margin:5px 20px 20px 0px;padding:0px;border:0px; Font-family:inherit;font-size:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height: Inherit;vertical-align:middle;height:auto; "/>
Swift Basic Tutorial (first Swift application)