gpt4 book ai didi

ios - ios自动布局中的VFL,如何完全填充 super View

转载 作者:行者123 更新时间:2023-11-29 02:30:09 26 4
gpt4 key购买 nike

我现在正在学习autolayout的VFL。我通过执行

将 View ( aview) 添加到 super View ( bview) 中
bview.addSubView(aview)

我希望我的aview填充整个bview,所以我的代码是:

    bview.addSubview(aview);
aview.setTranslatesAutoresizingMaskIntoConstraints(false)
bview.setTranslatesAutoresizingMaskIntoConstraints(false)
var lays = NSLayoutConstraint.constraintsWithVisualFormat("|-0-[aview]-0-|", options:NSLayoutFormatOptions.allZeros , metrics: nil, views: ["aview":aview] as NSDictionary)
bview.addConstraints(lays);
lays = NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[aview]-0-|", options:NSLayoutFormatOptions.allZeros , metrics: nil, views: ["aview":aview] as NSDictionary)

但是这段代码不能正确运行。我错过了什么吗?

最佳答案

您不需要-0-。只是简单地一无所有。例如:

bview.addSubview(aview);
aview.setTranslatesAutoresizingMaskIntoConstraints(false)
var lays = NSLayoutConstraint.constraintsWithVisualFormat("|[aview]|", options:NSLayoutFormatOptions.allZeros , metrics: nil, views: ["aview":aview] as NSDictionary)
bview.addConstraints(lays);
lays = NSLayoutConstraint.constraintsWithVisualFormat("V:|[aview]|", options:NSLayoutFormatOptions.allZeros , metrics: nil, views: ["aview":aview] as NSDictionary)

关于ios - ios自动布局中的VFL,如何完全填充 super View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27007825/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com