Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

字符串有多个\n出现的问题 #81

Open
Heisenbean opened this issue Oct 13, 2017 · 1 comment
Open

字符串有多个\n出现的问题 #81

Heisenbean opened this issue Oct 13, 2017 · 1 comment

Comments

@Heisenbean
Copy link

image

具体问题就是字符串有多个回车,Label限制行数,如果没显示完,MLLinkLabel不会有...,UILabel是有的

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *str =@"#2017北京诗歌节#《流浪的小狗》\n\n一道道隱匿的憂傷\n一曲曲哀婉的琴瑟夕陽\n還有我這只小狗正在流浪\n流浪,流浪\n沒有憐憫,沒有援扶 ";

    MLLinkLabel *l = [[MLLinkLabel alloc]init];
    l.numberOfLines = 3;
    l.frame = CGRectMake(12, 12, 0, 0);
    l.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 24;
    l.text = str;
    [l sizeToFit];
    [self.view addSubview:l];
    
    UILabel *l2 = [[UILabel alloc]init];
    l2.numberOfLines = 3;
    l2.frame = CGRectMake(12, 100, 0, 00);
    l2.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 24;
    l2.text = str;
    [l2 sizeToFit];
    [self.view addSubview:l2];
}
@Developer-LXP
Copy link

我这边遇到的问题跟你还有不一样,具体的问题是字符串与字符串之间有多个回车,Label限制行数,字符串与字符串之间的回车就没有了,如果不设置限制行数的话就显示正常;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants