【发布时间】:2020-02-28 11:02:49
【问题描述】:
我在 UIScrollView 中有一个 UIView 容器。但它没有显示在滚动视图中。当我检查调试视图层次结构时,宽度是不明确的。在这里我展示了图片和我的代码设置。
view.addSubview(scrollView)
scrollView.contentSize.height = 1000
scrollView.backgroundColor = #colorLiteral(red: 0.968627451, green: 0.968627451, blue: 0.968627451, alpha: 1)
scrollView.anchor(top: view.topAnchor, trailing: view.trailingAnchor, bottom: view.bottomAnchor, leading: view.leadingAnchor, topPadding: 0, rightPadding: 0, bottomPadding: 0, leftPadding: 0, width: 0, height: 0)
scrollView.addSubview(navigationView)
navigationView.addSubview(titleLbl)
navigationView.addSubview(profileIV)
navigationView.backgroundColor = .red
navigationView.anchor(top: scrollView.topAnchor, trailing: scrollView.trailingAnchor, bottom: nil, leading: scrollView.leadingAnchor, topPadding: 0, rightPadding: 0, bottomPadding: 0, leftPadding: 0, width: 0, height: 200)
titleLbl.anchor(top: navigationView.topAnchor, trailing: nil, bottom: nil, leading: navigationView.leadingAnchor, topPadding: 40, rightPadding: 0, bottomPadding: 0, leftPadding: 16, width: 50, height: 23)
profileIV.anchor(top: navigationView.topAnchor, trailing: nil, bottom: nil, leading: nil, topPadding: 80, rightPadding: 0, bottomPadding: 0, leftPadding: 0, width: 68, height: 68)
profileIV.centerXAnchor.constraint(equalTo: navigationView.centerXAnchor).isActive = true
profileNameLbl.anchor(top: profileIV.bottomAnchor, trailing: nil, bottom: nil, leading: nil, topPadding: 10, rightPadding: 0, bottomPadding: 0, leftPadding: 0, width: 0, height: 27)
profileNameLbl.centerXAnchor.constraint(equalTo: navigationView.centerXAnchor).isActive = true
【问题讨论】:
标签: ios swift uiscrollview