Objective c Xcode 5中的文本对齐
我的UILabel的代码:Objective c Xcode 5中的文本对齐,objective-c,text,xcode5,uilabel,center,Objective C,Text,Xcode5,Uilabel,Center,我的UILabel的代码: //Create the title of the tab here UILabel *title=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; title.text=@"Useful Websites"; title.textAlignment=UITextAlignmentCenter; [self.view addSubview:title]; 我知道iOS6不推荐使用a
//Create the title of the tab here
UILabel *title=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
title.text=@"Useful Websites";
title.textAlignment=UITextAlignmentCenter;
[self.view addSubview:title];
我知道iOS6不推荐使用assigner UITextAlignmentCenter。请您使用正确的赋值器/属性来将标签居中放置在Xcode 5和iOS7中,好吗?谢谢。使用:
title.textAlignment = NSTextAlignmentCenter;
带nstext对齐的开关
title.textAlignment=NSTextAlignmentCenter;
当您在XCode中编写时,当您开始键入“title.textAlignment”时,您将看到一条提示,告诉您该属性接受哪种类型。在本例中,NSTEXTALIGNING。是否需要删除initWithFrame?它似乎弄乱了文本的对齐。这不应该影响它,是iPhone的吗?如果是这样的话,将其设置为500像素将超出屏幕范围。如果文本在标签上居中,它将显示在屏幕上,因为标签悬挂在边缘180像素。非常感谢。你是为数不多的真正帮助过我并真诚地帮助过我的人之一!这对我来说非常有效。我需要删除initWithFrame吗?它似乎弄乱了文本的对齐方式。initWithFrame init如果标签具有所需的宽度和高度,可以尝试其他尺寸。