相关疑难解决方法(0)

UILabel文字边距

我正在设置a的左边插入/边距,UILabel但找不到这样做的方法.标签有一个背景设置,所以只是改变它的起源不会有效.10px左手边左右插入文本是理想的.

cocoa-touch uikit uilabel ios

307
推荐指数
21
解决办法
26万
查看次数

Swift 和 UILabel:如何以编程方式在 Swift 中添加填充和边距?

我使用 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)

storyboard uikit ios swift

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×2

uikit ×2

cocoa-touch ×1

storyboard ×1

swift ×1

uilabel ×1