I am using a UILabel
which is of 2 lines. I want to make it like
"Had the best experience ever! She is very gener... – Mary"
truncating middle portion but I am unable to achieve the same result.
Also consider that label
must be of 2 line and name at the end must appear. My code for label
for initialisation is as follow
self.labelMessage = [[VTUIKit labelSecondary] addToSuperview:self];
self.labelMessage.numberOfLines = 2;
self.labelMessage.font = kVTFontSecondaryVeryTiny;
self.labelMessage.textColor = kVTColorGrey300;
self.labelMessage.lineBreakMode = NSLineBreakByTruncatingMiddle;
self.labelMessage.f_width = [VTReviewDisplayCell cellSize].width - 16;
And for setting label
text
NSString *reviewString = [NSString stringWithFormat:@"%@ - %@", self.model.message, self.model.customer_user.first_name];
self.labelMessage.text = reviewString;
I dont understand why its not working properly.
Any help would be much appreciated.
Try with below code
UILabel *contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(40,100, 250, 60)];
contentLabel.numberOfLines = 2;
contentLabel.text = @"Had the best experience ever! She is very generally uwuq wuqe iwqwq – Mary";
contentLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
[self.view addSubview:contentLabel];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.