Swift Basic Tutorial (Swift code creates the first Uilabel of a control

Source: Internet
Author: User

The control that creates the view is similar to the previous one, with the creation of some views in the viewdidload.

First, set the frame to the label you want to create.

LetTextlabel =UILabel(Frame:CGRectMake( Self.View.Frame.size.width/8, -, Self.View.Frame.size.width*3/4, -))

Set a value for a label

Textlabel.text = "Now let's start learning how to create our first Swift control-uilabel"

Set whether to default line wrapping

textlabel.numberoflines  = 0

Set the label's background color

varWhitcolor =Uicolor(Red:1.0, Green:1.0, Blue:1.0, Alpha:1.0)

Textlabel. backgroundcolor = Whitcolor

Sets the text information presentation style for the label,

Textlabel.TextAlignment = Nstextalignment. Left

Set the font for a label

varTextfont =Uifont(Name:Nil, Size: One)

Textlabel. Font = Textfont

Set the text color of a label

varGreencolor =Uicolor(Red:0.9, Green:0.2, Blue:0.6, Alpha:1.0)

Textlabel. TextColor = Greencolor

Adding views to view

self . view . addsubview (Textlabel)


Swift Basic Tutorial (Swift code creates the first Uilabel of a control

Related Article

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.