在某个位置将UILabel分成两行

时间:2014-05-20 06:51:12

标签: ios ios7 uilabel

如果我有这样的UILabel:

 UILabel *errorLabel = [[UILabel alloc] initWithFrame:CGRectMake(30.0, 90.0, [self screenWidth] - 70.0, 50.0) ];
errorLabel.numberOfLines = 2.0;

errorLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:(12.0)];
errorLabel.text = @"Error: The email and/or password are incorrect. Try again.";

如何将文本分割为密码,以便将其吐出:

The email and/or password
are incorrect. Try again.

1 个答案:

答案 0 :(得分:1)

只需插入换行符:

errorLabel.text = @"Error: The email and/or password\nare incorrect. Try again.";

您已经设置了numberOfLines属性,这也很重要。