为什么 UIButton 比我设置的大

Why is the UIButton larger than I set it

我的 Xcode 项目中有一个 UIButton 有限制(见图 #3)。高度和宽度都设置为 80,但是当我 运行 项目时,它看起来比设置的要大。 (见图 #2)

在.m文件中,也设置为80x80(objective-c)

openMenu.layer.frame = CGRectMake(self.view.center.x - 27, self.view.frame.size.height - 80, 80, 80);

它应该看起来像:

图片 #1

图片 #2

图片 #3

注意:这些是实际尺寸(适合比例)

为什么它像图片 #2 一样大,我该如何修复它才能像图片 #1 一样保持 80x80?

您还应该在 Interface Builder 中设置 widthheight 约束。

这会将按钮图像调整为您想要的大小,并为其添加边距。

[openMenu setImageEdgeInsets:UIEdgeInsetsMake(25, 25, 25, 25)];

正在尝试添加 hieghtwidth 修复 约束 希望这会有所帮助。