UILabel controls for adding text to iOS

Source: Internet
Author: User

Uilabel is a control in iOS, is a subclass of UIView, but adds a text display function based on UIView. Uilabel is also a view using procedures and UIView similar
1. Create a View object
2. Configure View Properties
3. Add to Parent View

4. Release of ownership

1. Create an Object
UILabel *alabel = [[UILabel alloc] Initwithframe:cgrectmake (20, 100, 280, 40)];

2. Configuration Properties
(1.) Background color
Alabel.backgroundcolor = [Uicolor Graycolor];
(2) Display text
Alabel.text = @ " Tyyyyyyyrrrrrrrrrrrrrrrmwqqqqqqq346werrrrrrrrdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffjhgggggjhkkkkkkkk Kkkkkkkkkkk,yyyyyy ";
(3) Set the text to its way
Alabel.textalignment = Nstextalignmentcenter;
(4) Set text color
Alabel.attributedtext to set the color of each letter
Alabel.textcolor = [Uicolor Redcolor];
(5) Font style and size
Alabel.font = [Uifont systemfontofsize:26];

Alabel.font = [Uifont boldsystemfontofsize:26];

Alabel.font = [Uifont fontwithname:@ "Didot-italic" size:26];

(6) Shadow color
Alabel.shadowcolor = [Uicolor Bluecolor];
Alabel.shadowoffset = Cgsizemake (1, 1);
(7) The new line of VIP label
Alabel.numberoflines = 0;
(8) Whether the label modifies the font size according to its width
Alabel.adjustsfontsizetofitwidth = YES;
(9) How the line is intercepted
Alabel.linebreakmode = Nslinebreakbytruncatingmiddle;

3. Add to Parent View
[Containterview Addsubview:alabel];
4. Release of ownership
[Alabel release];

UILabel controls for adding text to iOS

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.