以编程方式在另一个视图(分层)边缘上的ios autolayout覆盖视图

时间:2015-07-28 22:06:39

标签: ios uiview autolayout uiview-hierarchy visual-format-language

这里我设计了一个自定义箭头,它将用作分享按钮。它应该固定在下边缘,其中心点固定在底部视图上,如图所示。

numpy.lib.stride_tricks.as_strided

我如何使用VFL做到这一点?

这就是我的尝试

whiteSquare

shareButtonshareButton都附加到超级视图。但这只是将$('#click').on('click',function(){ var code="<iframe width='1280' height='720' src='//www.youtube.com/embed/myvideoid?rel=0' frameborder='0' allowfullscreen=''></iframe>"; $('.container').append(code); }); 放在超视图的底部,而不是固定在whiteSquare底部的中心

1 个答案:

答案 0 :(得分:1)

You should position the share button relative to the white square and not the super view

This should do the trick:

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-10-[_whiteSquare(160)]-10-|"
                                                                  options:NSLayoutFormatDirectionLeadingToTrailing
                                                                  metrics:nil
                                                                    views:elementDict]];


[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_whiteSquare]-22.5-[_shareButton(45)]"
                                                                  options: NSLayoutFormatDirectionRightToLeft
                                                                  metrics:nil
                                                                    views:elementDict]];


[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[_whiteSquare]-10-|"
                                                                  options:NSLayoutFormatDirectionLeadingToTrailing
                                                                  metrics:nil
                                                                    views:elementDict]];

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[_whiteSquare]-22.5-[_shareButton(45)]"
                                                                  options:NSLayoutFormatDirectionRightToLeft
                                                                  metrics:nil
                                                                    views:elementDict]];