2017-09-06 4 views
0

Ich habe eine UILabel erstellt, die die Höhe basierend auf Zeichen setzt. Ich muss einige UIImageView s unter der veränderbaren UILable erstellen. Hier ist, was ich das Etikett zu schaffen machte:Position der Ansichten unter Selbstbemaßung UILabel

let productDescriptionLabel = UILabel(frame: CGRect(x: 10, y: imageViewHeight + 10, width: viewWidth - 20, height: 0)) 
productDescriptionLabel.textColor = UIColor.darkGray 
productDescriptionLabel.textAlignment = .right 
productDescriptionLabel.text = productsDescriptionArray! 
productDescriptionLabel.font = productDescriptionLabel.font.withSize(self.view.frame.height * self.relativeFontConstant) 
productDescriptionLabel.numberOfLines = 0 
let attrString = NSMutableAttributedString(string: productDescriptionLabel.text!) 
let style = NSMutableParagraphStyle() 
style.lineSpacing = 10 
style.minimumLineHeight = 20 
attrString.addAttribute(NSAttributedStringKey.paragraphStyle, value: style, range: NSRange(location: 0, length: (productDescriptionLabel.text?.characters.count)!)) 
productDescriptionLabel.attributedText = attrString 
productDescriptionLabel.sizeToFit() 
productDescriptionLabel.lineBreakMode = .byWordWrapping 
contentScrollView.addSubview(productDescriptionLabel) 

Nun frage ich mich, was ich definieren als die UIImageViewy:, um es direkt unter dem Label?

Antwort

0

Hoffe, das wird dir helfen. Erstellen Sie Ihre imageView nach der Label-Erstellung.

let imageView = UIImageView(frame: CGRect(x: 10, y: imageViewHeight + 10 + productDescriptionLabel.frame.size.height, width: viewWidth - 20, height: 0)) 
Verwandte Themen