First, mind map
Two
Code
//Create UIView and buttonsLet's views = UIView (Frame:cgrect (x:20, y:20, width:100, height:100))//fixme: Change ViewsframeViews.backgroundcolor =uicolor.yellow View.addsubview (views)//MARK: Create a buttonLet Button2 =UIButton (type:. Contactadd) Button2.backgroundcolor= uicolor.red//FIXME:SFSLButton2.frame =views.bounds Views.addsubview (Button2)//Button2. AddTarget (Self, Action: #selector (Button2click), for:)Button2.addtarget (Self, Action: #selector (Button2click), for:. Touchupinside)} //mark:--Methods Responsefunc Button2click () {print ("Button click") }
//Constants and variables
1Let A =Ten2Let b:double =105.33 //Binary operator ' + ' cannot is applied to operands of type ' Int ' and ' Double '4Print (A +Int (b))5 6 7var name:string ="Hello Word" //either the variable or the constant must be initialized, and the value of the constant cannot be changed8Name ="I am Hello Word"9Print (name)
Branching and//1 if f let a = ten if a > 5 { print ("a>5") }else{ print ("A<5") } // 23 Mesh / a > 5 print ("A large"): Print ("a small") //or write as a > 5? print ("A large"):()
Introduction to Swift and constants and variables---Introduction to Swift