2017-09-06 56 views
0

我创建了一个基于字符设置高度的UILabel。我需要在可调整大小的UILable下创建一些UIImageView。这是我做过什么来创建标签:下方自定义的视图位置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) 

嗯,我不知道我该怎么界定为UIImageViewy:,以作出正确的标签下面?

回答

0

希望这会帮助你。创建标签后创建您的imageView。

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