我正在设置a的左边插入/边距,UILabel但找不到这样做的方法.标签有一个背景设置,所以只是改变它的起源不会有效.10px左手边左右插入文本是理想的.
我使用 UILabel 以编程方式创建了一个带有灰色背景的文本。现在我想添加padding到这一段/文本中。另外,如果您能向我展示如何添加margin到我的UILabel中,那就太好了。
import UIKit
final class SignUpViewController: UIViewController {
public let identifier = "Sign Up"
private let logoImage : UIImageView = {
let imageView = UIImageView()
imageView.layer.masksToBounds = true
imageView.contentMode = .scaleAspectFit
imageView.image = UIImage(named: "MyLogoWithTitle")
imageView.clipsToBounds = true
return imageView
}()
private let instructionText : UILabel = {
let label = UILabel()
label.text = "Please read terms and conditions below carefully before proceeding with the registration."
label.backgroundColor = UIColor().colorFromHex(hex: "#2C333C", opacity: 0.4) …Run Code Online (Sandbox Code Playgroud)