047 set text line wrapping and ellipsis modes

Source: Internet
Author: User

The effect is as follows:

ViewController.h

1 #import <UIKit/UIKit.h>23@interface  viewcontroller: Uiviewcontroller4 @property (Strong, Nonatomic) UILabel *lblmessage; 5 6 @end

Viewcontroller.m

1 #import "ViewController.h"2 3 @interfaceViewcontroller ()4 @end5 6 @implementationViewcontroller7 8- (void) Viewdidload {9 [Super Viewdidload];Ten      OneSelf.title =@"LineBreak"; ASelf.view.backgroundColor =[Uicolor Blackcolor]; -      -_lblmessage = [[UILabel alloc] Initwithframe:cgrectmake ( -, -, the,460)]; the_lblmessage.text =@"Click on the screen to set the text line break and omit mode; Something you can try to do."; -_lblmessage.textcolor = [Uicolor colorwithred:0.335Green0.915Blue1.000Alpha1.000]; -_lblmessage.textalignment =Nstextalignmentleft; -_lblmessage.backgroundcolor = [Uicolor colorwithred:0.852Green0.941Blue1.000Alpha1.000]; +_lblmessage.linebreakmode = Nslinebreakbytruncatingtail;//The default value is Nslinebreakbytruncatingtail, and the trailer is truncated . - [Self.view addsubview:_lblmessage]; + } A  at- (void) didreceivememorywarning { - [Super didreceivememorywarning]; -     //Dispose of any resources the can be recreated. - } -  - #pragmaMark-private Methods in- (void) touchesended: (Nsset *) touches withevent: (Uievent *)Event { -     StaticNsuinteger i =1; to     Switch(i%6) { +          Case 0: -_lblmessage.linebreakmode = Nslinebreakbytruncatingtail;//truncated trailing ellipsis mode; default value the_lblmessage.text =@"Nslinebreakbytruncatingtail;something can try to do."; *              Break; $          Case 1:Panax Notoginseng_lblmessage.linebreakmode = Nslinebreakbytruncatinghead;//cut off the head ellipsis mode -_lblmessage.text =@"Nslinebreakbytruncatinghead;something can try to do."; the              Break; +          Case 2: A_lblmessage.linebreakmode = Nslinebreakbytruncatingmiddle;//cut off intermediate ellipsis mode the_lblmessage.text =@"Nslinebreakbytruncatingtail;something can try to do."; +              Break; -          Case 3: $_lblmessage.linebreakmode = nslinebreakbyclipping;//cut off the tail. $_lblmessage.text =@"Nslinebreakbyclipping;something can try to do."; -              Break; -          Case 4: the_lblmessage.linebreakmode = nslinebreakbycharwrapping;//cut off the tail in the form of a character split -_lblmessage.text =@"Nslinebreakbycharwrapping;something can try to do.";Wuyi              Break; the          Case 5: -_lblmessage.linebreakmode = nslinebreakbywordwrapping;//cut off the tail with a word (half character) split Wu_lblmessage.text =@"Nslinebreakbywordwrapping;something can try to do."; -              Break; About     } $i++; - } -  - @end

047 set text line wrapping and ellipsis modes

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.