这是我的代码:

UILabel *myLabel;
myLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 300, 480)];
myLabel.lineBreakMode = UILineBreakModeWordWrap;
myLabel.numberOfLines = 2; // 2 lines ; 0 - dynamical number of lines
myLabel.text = @"Please select at least one image category!";
myLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size: 24.0];
myLabel.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
myLabel.backgroundColor = [UIColor clearColor];
[self.view addSubview:myLabel];
[myLabel release];

我想知道是否有可能将包装好的文本居中,因为它位于左侧:

最佳答案

myLabel.textAlignment=UITextAlignmentCenter;

关于iphone - UILabel Center内容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4457779/

10-10 04:52