How to use Ios--uilabel details

Source: Internet
Author: User

How to use Ios--uilabel details

Use of Uilabel

UILabel *onelabel = [[UILabel alloc] init];

The most frequently used

Onelabel.frame = CGRectMake (0, 0, 320, 200); Setting the location and size of the Onelabel

Onelabel.text = @ "I am a uilabel oh,"; Set the word onelabel display

Onelabel.textcolor = [Uicolor blackcolor]; Set Font Color

Onelabel.backgroundcolor = [Uicolor Redcolor]; Set Background color

Onelabel.backgroundcolor = [Uicolor Clearcolor]; You can set a transparent background color

Onelabel.alpha = 1.0; Set transparency (range is between 0.0-1.0)

Font and font size

Onelabel.font = [Uifont fontwithname:@ "Helvetica" size:25.4f]; Sets the font and size of the displayed words, and when the font does not exist, the size is also invalid

Onelabel.font = [Uifont systemfontofsize:35.0f]; Set Font size only

Onelabel.font = [Uifont boldsystemfontofsize:35.0f]; Sets the font size and is bold

Onelabel.textalignment = Nstextalignmentcenter; Set the display position of the font: left, center, right

Onelabel.adjustsfontsizetofitwidth = YES; Set the font size to automatically fit the height

onelabel.userinteractionenabled = YES; Set whether you can interact with users

onelabel.enabled = YES; Sets whether the text of the Onelabel can be changed, by default Yes

Set the number of rows, provided that the height is sufficient

Set the number of rows to 0, you can calculate the height width of the corresponding text according to the text, full display, the default single row display

Onelabel.numberoflines = 3;

Set whether you can highlight

onelabel.highlighted = YES;

Onelabel.highlightedtextcolor = [Uicolor Redcolor];

Set Shadow

Onelabel.shadowcolor = [Uicolor Graycolor];

Onelabel.shadowoffset = Cgsizemake (2.0, 2.0);

Set the display format when text is too long

Onelabel.linebreakmode = nslinebreakbyclipping;

typedef ns_enum (Nsinteger, Nslinebreakmode) {

nslinebreakbywordwrapping = 0,

Nslinebreakbycharwrapping,

Nslinebreakbyclipping,

Nslinebreakbytruncatinghead,

Nslinebreakbytruncatingtail,

Nslinebreakbytruncatingmiddle

//    }

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

Onelabel.baselineadjustment = Uibaselineadjustmentalignbaselines;

typedef enum {

Uibaselineadjustmentalignbaselines,

Uibaselineadjustmentaligncenters,

Uibaselineadjustmentnone,

} uibaselineadjustment;

Add Onelabel to view and free up memory

[Self.view Addsubview:onelabel];

[Onelabel release], Onelabel = nil;

Report:

NSLog (@ "%@", [Uifont familynames]); Can print out all the fonts that exist

How to use Ios--uilabel details

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.