首页 > 解决方案 > 我如何在swift中的属性之间提供垂直空间

问题描述

func showContactInformation(){
    scrollView.addSubview(contactHeader)
    contactHeader.anchor(leadTitle.bottomAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 16, leftConstant: 16, bottomConstant: 0, rightConstant: 16, widthConstant: view.frame.width, heightConstant: 40)
    
    
    let contTitle_attribute = NSMutableAttributedString(string: "Customer", attributes: [NSAttributedString.Key.font: UIFont.openSansRegular_12])
    contTitle_attribute.append(NSAttributedString(string: "\nEmail", attributes: [NSAttributedString.Key.font: UIFont.openSansRegular_12]))
    contTitle_attribute.append(NSAttributedString(string: "\nPhone", attributes: [NSAttributedString.Key.font: UIFont.openSansRegular_12]))
    contactTitle.attributedText = contTitle_attribute
    
    
    let contactDetail_attribute = NSMutableAttributedString(string: "Ehsan", attributes: [NSAttributedString.Key.font: UIFont.openSansRegular_12])
    contactDetail_attribute.append(NSAttributedString(string: "\nien77@gmailcom", attributes: [NSAttributedString.Key.font: UIFont.openSansRegular_12]))
    contactDetail_attribute.append(NSAttributedString(string: "\n34343434", attributes: [NSAttributedString.Key.font: UIFont.openSansRegular_12]))
    contactDetail.attributedText = contactDetail_attribute
    
    
    let stackView = UIStackView(arrangedSubviews: [contactTitle, contactDetail])
    stackView.distribution = .fillEqually
    stackView.translatesAutoresizingMaskIntoConstraints = false
    stackView.spacing = 5
    stackView.alignment = .leading
    stackView.axis = .horizontal
    scrollView.addSubview(stackView)
    stackView.anchor(contactHeader.bottomAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 16, leftConstant: 16, bottomConstant: 0, rightConstant: 16, widthConstant: view.frame.width, heightConstant: 90)
    
}

标签: swift

解决方案


推荐阅读