如何将UILabel的基线与UIImageView的底部alignment?

我正在尝试将UILabel的基线与UIImageView的底部alignment。 我发现我无法select标签的基线作为标签的属性。 但是,我也发现如果用另一个标签replace图像视图,我可以使用基线。

有没有办法将标签的基线与图像底部alignment?

在这里输入图像说明

有一些事情的笔尖编辑器不会让你这样做。 您将需要在代码中configuration该约束。

这是你可以通过编程来完成的:

NSLayoutConstraint *layoutConstraint = [NSLayoutConstraint constraintWithItem:_imageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:_textLabel attribute:NSLayoutAttributeBaseline multiplier:1.0f constant:0]; [self.view addConstraint:layoutConstraint];