我有一个 ImageView 和一个 UILabel 都从上到上对齐。
它们彼此相邻,所以我有标签,然后是文本视图。现在,当标签中有文本时,文本的第一个字母低于 ImageView 的顶部。我希望文本的第一个字母始终与 ImageView 的顶部对齐。所以现在我将文本 -3 点对齐到 imageView 的顶部,然后它就可以工作了。但我不想使用幻数。
这是我正在使用的约束
self.iconImageView.autoSetDimension(.Height, toSize: 10)
self.iconImageView.autoSetDimension(.Width, toSize: 10)
self.iconImageView.autoPinEdge(.Top, toEdge: .Top, ofView:self, withOffset: Constants.kMarginLarge)
self.iconImageView.autoPinEdge(.Left, toEdge: .Left, ofView:self, withOffset: Constants.kMarginNormal)
self.titleLabel.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 5)
self.titleLabel.autoPinEdge(.Top, toEdge: .Top, ofView: self.warningImageView, withOffset: -3)
self.titleLabel.autoPinEdge(.Left, toEdge: .Right, ofView:self.warningImageView, withOffset: 5)
self.titleLabel.autoPinEdge(.Right, toEdge: .Right, ofView:self, withOffset: -5)
有没有办法计算偏移量并考虑到第一个字母或其他东西?
截图: