我内部有一个主视图,而内部视图又有一个。此自定义视图的左侧为TextLines,右侧为Image View。我正在更改约束,以将图像向左移动,文本行向右移动。但是它会缩小视图并显示宽度等于图像的视图。
NSLayoutConstraint primaryMainImageLeadingConstraint = NSLayoutConstraint.Create(primaryImage, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, showTextLinesAndMainIconsView, NSLayoutAttribute.Leading, 1, 0);
NSLayoutConstraint showTextLinesTrailingConstraint = NSLayoutConstraint.Create(mainTextField1, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, showTextLinesAndMainIconsView, NSLayoutAttribute.Trailing, 1, 0);
NSLayoutConstraint primaryImageShowTextHorizontalSpacingConstraint = NSLayoutConstraint.Create(mainTextField1, NSLayoutAttribute.Leading, NSLayoutRelation.GreaterThanOrEqual, primaryImage, NSLayoutAttribute.Trailing, 1, 300);
private void SetGraphicWithTextLayout()
{
this.View.AddConstraint(primaryMainImageLeadingConstraint);
this.View.AddConstraint(showTextLinesTrailingConstraint);
this.View.AddConstraint(primaryImageShowTextHorizontalSpacingConstraint);
}