Creation of Swift Base controls

Source: Internet
Author: User

 /* Let apples = 3 let orange = 5 let L = 1.1 let Applesummary = "I has \ (apples) apples"        Let fruitsummary = "I had \ (apples + orange) pieces of fruit." Let Isay = ' I love \ (L) you ' Print (isay) Let explicifloat:float = 4//print (fruitsummary) PR Int (explicifloat) Let label = "label" Let width = 94 let Widthlabel = Label + String (width) pr int (widthlabel) */        / * Initialize an array with a value array * /var shoppinglist = ["Catfish","Water","Tulips","agg","Water"] var dic = ["A":"a","B":"B",] shoppinglist[1] ="AAAAAA"Print (shoppinglist[0])/* Initialize an empty array and dictionary */Let Emptyarray = string["",""] () Let emptydictionary = Dictionary<string, Float > () print (emptydictionary) Let Textlabel = UILabel (Frame:cgrectmake (self. View. Frame. Size. Width/8, -, self. View. Frame. Size. Width*3/4, -)//Give label value Textlabel. Text="Now let's start learning how to create our first Swift control-uilabel"Sets whether to default line wrapping Textlabel. NumberOfLines=0Sets the label's background color var whitcolor = Uicolor (red:1.0, Green:1.0, Blue:1.0, Alpha:1.0) Textlabel. BackgroundColor= Whitcolor Self. View. Addsubview(Textlabel)//view Let view = UIView (Frame:cgrectmake ( -, -, -, -)) View. BackgroundColor= Uicolor. Bluecolor() Self. View. Addsubview(view)//textfield Let TextField = Uitextfield (Frame:cgrectmake ( -, $, $, -)) TextField. Text="haha"TextField. TextColor= Uicolor. Redcolor() Self. View. Addsubview(TextField)//button Let button = UIButton (Frame:cgrectmake ( -, -, Max, -)) button. BackgroundColor= Uicolor. Purplecolor() button. Titlelabel?. Text="1111"button. AddTarget(Self, Action:selector ("ButtonClick:"), forcontrolevents:uicontrolevents. Touchupinside) Self. View. Addsubview(button)//imageview let ImageView = Uiimageview (Frame:cgrectmake ( -, -, -, -)) ImageView. Image= UIImage (named:"Unknown") Self. View. Addsubview(ImageView)} Button listener func buttonclick (Btn:uibutton) {print (btn. Titlelabel?. Text)        }! such as (http://img. Blog. Csdn. NET/20150605234753408)

Creation of Swift Base controls

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.