0

I wanted to make it like this:

enter image description here

into this

enter image description here

because im having trouble merging a UIButton and UILabel together

The My Current Code is this:

//UIStackView
lazy var infoHelpFooterStack : UIStackView = {
        lazy var infoContact : UILabel = {
            let label = UILabel()
            label.translatesAutoresizingMaskIntoConstraints = false
            label.font = AppFont.regular.size(14)
            label.text = "Still need help? Send a message to the support team"
            label.numberOfLines = 0
            label.textColor = AppColors.primaryBlue
            label.textAlignment = .left
            return label
        }()
        
        let stack = UIStackView(arrangedSubviews: [infoContact,contactButton])
        stack.translatesAutoresizingMaskIntoConstraints = false
        stack.axis = .horizontal
        stack.distribution = .fillProportionally
        stack.spacing = 3
        return stack
    }()
// UIButton

lazy var contactButton: UIButton = {
        let button = UIButton()
        button.setTitle("Contact Support", for: .normal)
        button.setTitleColor(AppColors.primaryBlue, for: .normal)
        button.titleLabel?.font = AppFont.semiBold.size(17)
        button.withWidth(170)
        button.withHeight(190)
        button.addTarget(self, action: #selector(contactButtonTapped), for: .touchUpInside)
        return button
    }()

Tj3n
  • 9,837
  • 2
  • 24
  • 35
  • `UIStackView` won't work in this case, you have to use `NSAttributedString` and handle the local link tapped. – Tj3n Oct 05 '22 at 07:02
  • Although it's possible to use separate UI elements for that and place them on top of each other, calculating the place for the button would be a nightmare (given that the label is relatively dynamic and its text is positioned a bit differently for different screens). Instead, it's much easier to use the approach pointed out by @Tj3n, as it's the most common one in the UIKit world. – lazarevzubov Oct 05 '22 at 08:26
  • actually its not use for links but it does work but I needed it to pass it over to a viewcontroller – Brinkster129 Oct 10 '22 at 01:24

0 Answers0