Swift--label

Source: Internet
Author: User

Swift code creates the Uilabel of the first control

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.

Let Textlabel = UILabel (Frame:cgrectmake (self.view.frame.size.width/8,20,self.view.frame.size.width*3/4,100))

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

var whitcolor = 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

var textfont = Uifont (Name:nil, Size:11)

Textlabel.font = Textfont

Set the text color of a label

var greencolor = 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--label

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.