现在我已经看到很多例子教你如何将 UILabel 文本放在屏幕中间,但这不是我想要的。我在问如何确保 UILabel 的文本保持在屏幕左右边界之间的中间,我所要做的就是垂直调整。我有以下内容:
self.aboutMee = [[UILabel alloc] initWithFrame:CGRectMake(0, 400, 120, self.view.bounds.size.width)];
self.aboutMee.text = @"About Me";
self.aboutMee.textAlignment = NSTextAlignmentCenter;
self.aboutMee.backgroundColor = [UIColor clearColor];
self.aboutMee.font = [UIFont fontWithName:@"Helvetica" size:14];
[self.aboutMee setTextColor:[UIColor colorWithRed:0.0/255.0 green:140.0/255.0 blue:199.0/255.0 alpha:1.0]];
[self.aboutMee setFont:[UIFont fontWithName:@"HelveticaNeueLTStd-ThCn" size:35]];
[self.scrollView addSubview:self.aboutMee];
现在我尝试将整个标签的宽度设为 320,然后将文本居中,但这不起作用。有任何想法吗?