Detailed use of the iOS UILabel (Label control) and special effects

Source: Internet
Author: User
Tags transparent color

UILabel *label = [[Uilabelalloc] initwithframe:cgrectmake (0, 0, 75, 40)]; Declare Uilbel and specify its position and length width

Label.backgroundcolor = [Uicolorclearcolor]; Sets the label's background color, which is set to a transparent color.

Label.font = [Uifont fontwithname:@ "Helvetica-bold" size:13]; Sets the font and font size of the label.

Label.transform = Cgaffinetransformmakerotation (0.1); Set the rotation angle of a label

Label.text = @ "HelloWorld"; Set the text that the label displays

Label.textcolor = [Uicolorwhitecolor]; Set the color of text

Label.shadowcolor = [uicolorcolorwithwhite:0.1falpha:0.8f]; Sets the shadow color and transparency of the text.

Label.shadowoffset = Cgsizemake (2.0f, 2.0f); Sets the tilt angle of the shadow.

Label.textalignment = Uitextalignmentcenter; Sets the position of the text to be displayed in the label, centered here.

Line wrapping: The following line breaks enable multiple lines of display, but requires a label to be of sufficient width.

Label.linebreakmode = Uilinebreakmodewordwrap; Specify line break mode

Label.numberoflines = 2; Specify the number of rows for a label

The rotation of the lable

Label.transform = cgaffinetransformmakerotation (0.2); Set the rotation angle of a label

[Self.view Addsubview:label]; Load a label into

Label beautification and Effects:

Here use Fxlabel to achieve special effects, such as the "daily" word is used Fxlabel to achieve, but to join FXLbal.h and fxlabel.m two files, the specific code is as follows.

Fxlabel *label = [[Fxlabelalloc] initwithframe:cgrectmake (0, 0, 100, 30)];

Label.backgroundcolor = [Uicolorclearcolor];

Label.font = [uifontfontwithname:@ "Helvetica-bold" size:15];

Label.text = [Secondtitle objectatindex:i];

Label.textcolor = [Uicolorgraycolor];

Label.shadowcolor = [uicolorcolorwithwhite:1.0falpha:0.8f];

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

Label.shadowblur = 1.0f;

Label.innershadowcolor = [uicolorcolorwithwhite:0.0falpha:0.8f];

Label.innershadowoffset = Cgsizemake (1.0f, 2.0f);

Label.textalignment = Uitextalignmentleft;

[View Addsubview:label];

Its usage and Uilabel difference is not small, very good understanding, code can be called directly, the specific properties of their own modification. The effect is as follows:

You can go to http://www.cocoachina.com/downloads/code/2011/1108/3463.html to download the instance code, remember to copy the Fxlabel header files and source files to join your own project, So you can use the Fxlbel freely.

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.