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)
オフセットを計算し、最初の文字などを考慮に入れる方法はありますか?
スクリーンショット: