我无法弄清楚如何在图像视图中使标签水平居中,标签显示为What would you rate us
,我希望"You've been here."
位于File file = new File("C:\\Example");
String[] myFiles;
if (file.isDirectory()) {
myFiles = file.list();
for (int i = 0; i < myFiles.length; i++) {
File myFile = new File(file, myFiles[i]);
myFile.delete();
}
}
我尝试的内容之下要做到这一点,就是在标签上添加2行,选择标签加上3个按钮,然后单击“添加缺失约束”。当我运行程序时,这就是结果。
如何修复它以便在所有设备上输入文字?
约束
答案 0 :(得分:14)
答案 1 :(得分:0)
点击标签
1.Don't set any heights
2.Now set top space to the container view
3.centre horizontal to container view
4.now set the height (or) bottom space to the smiley
Add this all constraints you will get what you expected :)
答案 2 :(得分:0)
答案 3 :(得分:0)
只需使用此代码:
yourLabel.translatesAutoresizingMaskIntoConstraints = YES;
CGPoint centerPoint = yourLabel.center;
centerPoint.x = yourImageView.center.x;
yourLabel.center = centerPoint;