开发者

want to display multiple lines in custom cell label

开发者 https://www.devze.com 2022-12-08 14:16 出处:网络
I have a label in a custom cell with 3 labels in a table view. I am trying to display a text message \"Updated status one of user\" in one of the labels, but it displays only \"Updated status\" and tr

I have a label in a custom cell with 3 labels in a table view. I am trying to display a text message "Updated status one of user" in one of the labels, but it displays only "Updated status" and truncates the rest of the message. What can I tweek to display the whole message in a line or sp开发者_运维技巧ill it to a second line is necessary? Appreciate your suggestions.


Well, set the number of lines of your label to 0, and set its lineBreakMode to UILineBreakModeWordWrap if you want the text to wrap to more lines if it doesn't fit. Else, try increasing the width of your label.


you can try this sample custom label creation in objective c and also how we can display no of lines in label , fallow the comments in below code it's useful to simply understand...

in .h

UILabel *label;

in .m

- (void)viewDidLoad
{  

     label=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 60, 60)];

     label.text=@"HI EVERY BODY >>> GOOD MORNING TO ALL MY DEAR FRIENDS";

     label.numberOfLines=2;  // for example i gave 2 lines , you can give how many lines  you want 

     label.lineBreakMode=UILineBreakModeWordWrap; // you must have to specify line Break mode

     [self.view addSubview:label];

[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

}

Thank you...


You can try to use UILabel's adjustsFontSizeToFitWidth property for that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号