Simple use of uilabel

Source: Internet
Author: User

Uilabel * oper2 = [[uilabelalloc] initwithframe: cgrectmake (200,
100, 30, 30)]; // Initialization

Oper2.text = @ "= ";

Oper2.textcolor = [uicolorblackcolor]; // The font is black.

Oper2.backgroundcolor = [uicolorclearcolor]; // clear the background color.

Oper2.textalignment = 1; // center

Oper2.font = [uifont
Systemfontofsize: 25];
// Font size

Oper2.shadowoffset = cgsizemake (2,
1); // The offset position of the shadow

Oper2.shadowcolor = [uicolorgraycolor]; // shadow color

[Self. View
Addsubview: oper2]; // load the display

[Oper2 release]; // Memory Management

Change height with words

// Initialize uilable to display the cinema route

Uilabel * buslinelbl = [uilabel
Labelwithframe: cgrectmake (num_ten,
Num_ten, SCREENFRAME_WIDTH-2 * num_ten,
(100) text: [nsstring
Stringwithformat: @ "route: % @", [self. cinemamessage
Objectforkey: @ "busline"] textcolor: [uicolor
Whitecolor] setfont: [uifont
Systemfontofsize: num_thirteen];

Buslinelbl. linebreakmode
= Nslinebreakbycharwrapping; // set the automatic line feed.

Buslinelbl. numberoflines =
10; // set the number of rows

Cgsize size = cgsizemake (buslinelbl. Frame. Size. Width, 200 );
// Set the width and height. The height indicates the maximum allowed height.

Cgsize labelsize = [buslinelbl. Text
Sizewithfont: buslinelbl. Font
Constrainedtosize: Size linebreakmode: 1];
// Obtain the label size through the number of words in the text _ lblcontent. text, the font size, the height and mode of the limit.

[Buslinelbl setframe: cgrectmake (buslinelbl. Frame. Origin. X, buslinelbl. Frame. Origin. Y, labelsize. Width, labelsize. Height)];
// Set the frame of the label based on the size.

[Scroll addsubview: buslinelbl]; // load on the scroll View

Cgsize size = cgsizemake (_ lblcontent. Frame. Size. Width, 10000); // set the width and height, where the height is the maximum allowed height.

Cgsize labelsize = [_ lblcontent. text sizewithfont: _ lblcontent. font constrainedtosize: Size linebreakmode: uilinebreakmodewordwrap]; // use text _ lblcontent. the number of words in text, the font size, the limited height, and the mode to obtain the label size.

[_ Lblcontent setframe: cgrectmake (_ lblcontent. frame. origin. x, _ lblcontent. frame. origin. y, labelsize. width, labelsize. height)]; // Finally, set the frame of the label based on the size.



Uifont font setting

Label. font = [uifont fontwithname: @ "Arial-bolditalicmt" Size: 24];

 

The name is as follows:

Font family: American typewriter

Font: americantypewriter

Font: americantypewriter-bold

Font family: applegothic

Font: applegothic

Font family: Arial

Font: arialmt

Font: Arial-boldmt

Font: Arial-bolditalicmt

Font: Arial-italicmt

Font family: Arial rounded Mt bold

Font: arialroundedmtbold

Font family: Arial Unicode MS.

Font: arialunicodems

Font family: courier

Font: courier

Font: courier-boldoblique

Font: courier-oblique

Font: courier-bold

Font family: Courier New

Font: couriernewps-boldmt

Font: couriernewps-italicmt

Font: couriernewps-bolditalicmt

Font: couriernewpsmt

Font family: db LCD temp

Font: dblcdtempblack

Font family: Georgia

Font: Georgia-bold

Font: Georgia

Font: Georgia-bolditalic

Font: Georgia-italic

Font family: Helvetica

Font: Helvetica-oblique

Font: Helvetica-boldoblique

Font: Helvetica

Font: Helvetica-bold

Font family: Helvetica Neue

Font: helveticaneue

Font: helveticaneue-bold

Font family: hiragino Kaku Gothic ***** W3

Font: HiraKakuProN-W3

Font family: hiragino Kaku Gothic ***** w6

Font: HiraKakuProN-W6

Font family: marker felt

Font: markerfelt-thin

Font family: stheiti J

Font: stheitij-Medium

Font: stheitij-light

Font family: stheiti K

Font: stheitik-Medium

Font: stheitik-light

Font family: stheiti SC

Font: stheitisc-Medium

Font: stheitisc-light

Font family: stheiti TC

Font: stheititc-light

Font: stheititc-Medium

Font family: Times New Roman

Font: timesnewromanpsmt

Font: timesnewromanps-boldmt

Font: timesnewromanps-bolditalicmt

Font: timesnewromanps-italicmt

Font family: trebuchet MS

Font: trebuchetms-italic

Font: trebuchetms

Font: trebuchet-bolditalic

Font: trebuchetms-bold

Font family: verdana

Font: verdana-bold

Font: verdana-bolditalic

Font: verdana

Font: verdana-italic

Font family: zapfino

Font: zapfino

Uifont fontwithname does not know the font name. I have read all the solutions below!

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.