如何在 XCode 中将标签文本居中
我有一个带有两个标签的单元格。如何以编程方式居中对齐顶部标签并隐藏第二个标签?
I have a cell with two labels. How can I programmatically center-align the top label and hide the second label?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UITextAlignmentCenter
已弃用。您应该使用以下内容:UITextAlignmentCenter
is deprecated. You should use the following:[labelOne setTextAlignment:UITextAlignmentCenter]; //将文本置于 UILabel 中居中
[labelTwo setHidden:YES] //存在,但不可见。
[labelOne setTextAlignment:UITextAlignmentCenter]; //to center text in the UILabel
[labelTwo setHidden:YES] //there, but not visible.
我认为你想做的是:
像这样的东西..
您希望第一个标签中的文本位于单元格的中心吗?
I think what you are trying to do is:
Something like this..
you want you text from the firstLabel to be at the center of the cell?