IOS control label (uilabel)

Source: Internet
Author: User
Tags control label

I have already passed object-C some time ago. Now I want to start practical iOS development. Because it was previously done.. NET development, so there are still a lot of discomfort and confusion about the transfer time, especially C #-> Object-C and vs-> xcode, many of the ideas and operations are different, but there is no way to do it step by step.

Today, I am calling some simple controls in iOS, including using the label (uilabel). In fact, the label (uilabel) is quite simple, but it is also the most commonly used one, so I want to first get familiar with the label (uilabel) to get started with the controls in IOS. After all, the controls have many identical attributes and methods ~ Official Document: Apple label (uilabel) Description of the more important part of the label (uilabel) is as follows: The uilabel class implements a read-only text view. you can use this class to draw one or multiple lines of static text, such as those you might use to identify other parts of your user interface. the base uilabel class provides control over the appearance of your text, including whether it uses a shadow or draws with a highlight. if ne Eded, you can customize the appearance of your text further by subclassing. new label objects are configured to disregard user events by default. if you want to handle events in a custom subclass of uilabel, you must explicitly change the value of the userinteractionenabled property to yes after initializing the object. this article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original version Article
The first address of this article: IOS control label (uilabel)-www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html through these two paragraphs, we can understand that label (uilabel) has the following features: 1. It is used to display text content and is read-only 2. It can be displayed in a single row or multiple rows, but it must be set. 3. You can add some special effects such as shadow, draws, and highlight to the content. 4. events are not supported by default, but they can be customized for support. This article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
The first address of this article: IOS control label (uilabel)-www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html, to analyze the attributes of the label (uilabel) one by one ): 1. Text: Text displayed by label (uilabel). It can be read and written. The value type is nsstring and the default value is nil.

 2. Font:Font-family and font-size of text, which can be read and written. The value type is uifont and the default value is system font at a size of 17.

3. textcolor: Text color, read/write attribute, Value Type: uicolor, default value: Black
4. textalignment: Alignment of text, which can be read and written. The value type is uitextalignment. The default value is uitextalignmentleft.

5. linebreakmode: Text line feed and truncation, read/write attributes, Value Type: uilinebreakmode, default value: uilinebreakmodetailtruncation 6. Enabled: Whether the control is available. It seems that the label is quite tasteless. If it is set to false, the color is only dimmed. To hide the uilabel (Label), use the hidden attribute.
 
//Hide label (uilabel): lblusername[Lblusername sethidden:True];
This article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
The first address of this article is IOS control label (uilabel)-www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html 7. adjustsfontsizetofitwidth: Whether to automatically adjust the text size based on the label width. The default value is yes and bool. 8. baselineadjustment: The baseline position of text. It is not too long to understand ~ 9. minimumfontsize: The minimum text size. You can use this property to prevent adjustsfontsizetofitwidth from being too scaled. 10. numberoflines: Set the maximum line of text to avoid being too high. Set it to 0, that is, the number of rows is unlimited. 11. highlighted: Whether to highlight (for label, it is to change the color of text). This attribute is suitable for interaction time, such as button being pressed and then changing the color of button text. That is to say, only the time when the label is pressed. For example, there is another label in a tabelcell. When the tabelcell is pressed, the background color is changed to blue, turning the label's highlighted into white will make the experience better. 12. highlightedtextcolor: For more information about how to highlight the color, see highlighted. 13. shadowcolor & shadowoffset: Set the text shadow color and shadow size 14. userinteractionenabled: Whether to interact with the user, that is, whether the response time can be reached. The default value is no uilabel, which controls the height. There are two latitudes: numberoflines and frame; however, after use, it is found that numberoflines only 0 and 1 make sense, that is, the number of automatic lines and the number of 1 lines are displayed. If it is 0, adjust the height by setting the frame, that is to say, numberoflines can be used to control whether uilabel is displayed for multiple rows. In fact, they are replaced by ismulitrows. I feel better that this article prohibits reprinting of any websites and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
The first address of this article is IOS control label (uilabel)-www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html. Code :
Nsstring * TXT = @" The uilabel class implements a read-only text view. you can use this class to draw one or multiple lines of static text, such as those you might use to identify other parts of your user interface. \ n the base uilabel class provides support for both simple and complex styling of the label text. you can also control over aspects of appearance, such as whether the label uses a shadow or draws with a highlight. \ n if needed, you can customize the appearance of your text further by subclassing. the default content mode of the uilabel class is uiviewcontentmoderedraw. \ n this mode causes the view to redraw its contents every time its bounding rectangle changes. \ n you can change this mode by modifying the inherited contentmode property of the class. new label objects are configured to disregard user events by default. \ n if you want to handle events in a custom subclass of uilabel, you must explicitly change the value of the userinteractionenabled property to yes after initializing the object."  ; Learnlabel. Text = Txt; uifont * Font = [uifont systemfontofsize: 16  ]; Learnlabel. Font = Font;  /*  Test 1 sets the uilabel height  */  Learnlabel. numberoflines = 0  ; Cgsize txtsize =[TXT sizewithfont: font constrainedtosize: cgsizemake (  400 , 200  ) Linebreakmode: uilinebreakmodecharacterwrap]; learnlabel. Frame = Cgrectmake (learnlabel. Frame. Origin. X, learnlabel. Frame. Origin. Y, txtsize. Width, txtsize. Height );  /*  Test 3 to test highlightcolor & Highlight learnlabel. Highlighted = true; learnlabel. textcolor = [uicolor greencolor]; learnlabel. highlightedtextcolor = [uicolor bluecolor];  */          /* Test 4 test shadowcolor & shadowoffset  */  Learnlabel. Font = [Uifont systemfontofsize: 34  ]; Learnlabel. shadowcolor = [Uicolor greencolor]; learnlabel. shadowoffset = Cgsizemake ( 0.0 , 0.000001  ); Learnlabel. backgroundcolor = [Uicolor graycolor];  /* Test 2 sets automatic line feed and adaptive size learnlabel. linebreakmode = uilinebreakmodewordwrap; learnlabel. numberoflines = 0; cgsize size = [learnlabel sizethatfits: cgsizemake (500, 0)]; cgrect rect = learnlabel. frame; rect. size = size; learnlabel. frame = rect;  */ 

 

This article prohibits reprinting on any website and severely condemn the worms.
This article was first published in, blog garden. Please search: blog garden-Find yourself and view the original article
The first address of this article: IOS control label (uilabel)
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.