【问题标题】:Swift anchors of the same elements from each other彼此相同元素的 Swift 锚点
【发布时间】:2017-03-22 17:42:06
【问题描述】:

我在 Swift 中有一个 UIView

let postDiv: UIView = {
    let div = UIView()
    return div
}()
profile_view.addSubview(postDiv)
profile_view.addSubview(PostDiv)
profile_view.addSubview(PostDiv)

当我只添加其中一个作为子视图时,它可以工作,但是当我添加几个时,它们会相互重叠,所以只有它们是可见的,我怎样才能相互添加锚点。这是我当前的锚点

postDiv.anchor(postsDiv.bottomAnchor, left:view.leftAnchor, bottom: nil, right: view.rightAnchor, topConstant: 40, leftConstant: 15, bottomConstant: 0, rightConstant: 15, widthConstant: 0, heightConstant: 165)

【问题讨论】:

  • 请:将变量小写以区别于类!
  • 谢谢。 div也:)
  • @muescha 我将变量小写,因此您可以将它们与类区分开来
  • 请同时发布您的代码i add several
  • 也许UIStackView 是您要找的?

标签: ios swift


【解决方案1】:

在你的情况下,我会使用 UITableView 来获取你想要实现的行列表

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-06
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 2015-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多