简体   繁体   English

按钮文字出现在框架外

[英]Button text appearing outside frame

I have a UIButton set up in the interface builder and I have the following code in the viewDidLoad() method. 我在界面生成器中设置了UIButton,并且在viewDidLoad()方法中具有以下代码。

purchaseButtonOutlet.layer.cornerRadius = 8
purchaseButtonOutlet.titleLabel?.minimumScaleFactor = 0.01
purchaseButtonOutlet.titleLabel?.adjustsFontSizeToFitWidth = true

On bigger devices eg the iPad Pro, it works fine, but on smaller devices eg the iPhone SE, it doesn't work: 在较大的设备上,例如iPad Pro,它可以正常工作,但是在较小的设备上,例如iPhone SE,它不起作用:

在此处输入图片说明

Does anyone know why this is? 有人知道为什么是这样吗?

Try to set two constraints 尝试设置两个约束

  1. Vertically center to container 垂直居中居中
  2. Add 10 to left constraint 向左增加10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM