Step-by-step learning iOS, (Uilabel controls) detailed use and special effects

Source: Internet
Author: User

Basic Control-uikit Uilable

All 1..ios applications are based on the Uikit

2.UIWindow defines an object for a program display window

3.alloc Allocating memory init initialization

Declares the Uilabel and specifies its position and width

UILabel *labelname = [UILabel

Alloc]initcgrectmake (50.0,100.0,100.0,50.0);

Sets the background of labelname to red, or to other colors

Labelname.background = [Uicolor Redcolor];

Set the text that the label displays

labelName.Text = @ "Name:";

Set the color of the display text, I set it to Gray

Labelname.textcolor = [Uicolor Graycolor];

Set the rotation angle of the labelname

Labelname.transfrom = cgaffinetransformmakerotation (0.2);

Sets the position of text displayed in LabelName, Nsuitextalignmentright to the right

Nsuitextalinmentleft Left Nsuitextalignmentcentee Center

Labelname.textalignment = Nsuitextalignmentcentee;

Set font: Normal state is systemfontofsize

Labelname.font = [Uifont boldsystemfontofsize:20];

Set the shadow color of text

Labelname.shadowcolor = [Uicolor Redcolor];

Set the color and transparency of the shadow

Labelname.shadowcolor = [Uicolor colorwithwhite:0.1 alpha:0.8];

Set the position of the shadow text

Labelname.shadowoffset = Cgsizemake (1.0f,2.0f);

Set Highlight Color

labelname.highlighted = Yes;

Set the color of the highlighted font

Labelname.highlightedtextcolor = [Uicolor Orangecolor];

Set the number of lines for Lablename, I set 2 rows

Labelname.numberoflines = 2;

Set whether you can interact with users

labelname.userinteractionenabled = Yes;

Sets whether the text in the LabelName is mutable, and the default value is Yes

labelname.enabled = NO;

Set the display format when the text is too long, I'm intercepting the middle part

Labelname.linebreakmode = uilinebreakmodemiddletruncation;

typedef enum{

Uilinebreakmodewordwrap = 0;

Uilinebreakmodecharacterwrap;

uilinebreakmodeclip;//Intercept Superfluous parts

uilinebreakmodeheadtruncation;//intercept the head.

uilinebreakmodetailtruncation;//Intercept Tail

uilinebreakmodemiddletruncation;//Intercept the middle

}uilinebreakmode;

If the Adjustsfontsizetofitwidth property is set to Yes, this property controls the behavior of the text baseline

Step-by-step learning iOS, (Uilabel controls) detailed use and special effects

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.