我正在尝试显示包含缩略图和标题的行。
它适用于短标题字符串,但对于长字符串,它会中断。与其横向扩展,我更希望它纵向扩展。查看下面的屏幕截图,看看使用长字符串时会发生什么。我正在使用PureLayout来管理自动布局:
thumbnailView.autoSetDimensions(to:CGSize(width: 75, height: 75))
thumbnailView.autoPinEdge(toSuperviewEdge: .leading, withInset: kLabelHorizontalInsets)
thumbnailView.autoPinEdge(toSuperviewEdge: .top, withInset: kLabelVerticalInsets)
thumbnailView.autoPinEdge(toSuperviewEdge: .bottom, withInset: kLabelVerticalInsets, relation: .greaterThanOrEqual)
titleLabel.autoPinEdge(.leading, to: .trailing, of: thumbnailView, withOffset: kLabelHorizontalInsets, relation: .lessThanOrEqual)
titleLabel.autoPinEdge(toSuperviewEdge: .top, withInset: kLabelVerticalInsets)
titleLabel.autoPinEdge(toSuperviewEdge: .trailing, withInset: kLabelHorizontalInsets)
titleLabel.autoPinEdge(toSuperviewEdge: .bottom, withInset: kLabelVerticalInsets)
还设置了 UITextLabel 上的相应设置:
titleLabel.lineBreakMode = .byWordWrapping
titleLabel.numberOfLines = 0
titleLabel.textAlignment = .left