Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 UIbutton,里面有一些居中的文本。当我以编程方式更新文本时,使用:button.titleLabel.text = newValue;它不再居中,而是它有一个非常奇怪的位置(不居中,也不左对齐)......我怎样才能让按钮更新文本以水平居中?
button.titleLabel.text = newValue;
UIButton 的标题应该使用 setTitle:forState: 方法设置。