Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 是什么导致UIButton标题周围出现水平填充?_Ios_Uibutton_Ios12 - Fatal编程技术网

Ios 是什么导致UIButton标题周围出现水平填充?

Ios 是什么导致UIButton标题周围出现水平填充?,ios,uibutton,ios12,Ios,Uibutton,Ios12,我以编程方式创建了两个UIButtons,并将它们限制为相隔2点(水平)。我看到了额外的空间,所以我单击了Xcode中的“调试视图层次结构”按钮,下面是我看到的: 是什么导致“abc”标题周围出现额外的空格?我查看了按钮的一些可疑属性,它们都是零。(contentEdgeInsets,titleEdgeInsets) 我没有对按钮做任何操作,除了: let b = UIButton(type: .system) b.translatesAutoresizingMaskIntoConstrain

我以编程方式创建了两个
UIButton
s,并将它们限制为相隔2点(水平)。我看到了额外的空间,所以我单击了Xcode中的“调试视图层次结构”按钮,下面是我看到的:

是什么导致“abc”标题周围出现额外的空格?我查看了按钮的一些可疑属性,它们都是零。(
contentEdgeInsets
titleEdgeInsets

我没有对按钮做任何操作,除了:

let b = UIButton(type: .system)
b.translatesAutoresizingMaskIntoConstraints = false
b.setTitle("...", for: .normal)
约束条件如下所示:

b1.centerXAnchor.constraint(equalTo: outer.centerXAnchor)
b2.leftAnchor.constraint(equalTo: b1.rightAnchor, constant: 2)
b2.firstBaselineAnchor.constraint(equalTo: b1.firstBaselineAnchor, constant: 0)  

ui按钮
的固有最小宽度为30分

因此,如果标题文本短于30磅,则按钮的标题标签将在按钮的30磅框架中水平居中

您可以显式地将宽度设置为小于30,但随后您必须采取一些其他步骤,以使按钮自动调整为具有较长标题的大小