在阅读了苹果网站上的技术说明并阅读了有关使用Autolayout的UIScrollview的iOS 11编程的亚特布尔诺布书后,我无法完全理解这一切的概念.
基本上我想要的是一个Scrollview,它有一个子视图ChildView,其中这个子视图有一个Textview.
下面我附上了我试图以编程方式实现的无模型,没有故事板的模型.
至于代码,这就是我通常提出的:
码
let Scroller: UIScrollView = {
let scroll = UIScrollView()
scroll.translatesAutoresizingMaskIntoConstraints = false
scroll.backgroundColor = UIColor.alizarinColor()
return scroll
}()
// Content view
let ContentView : UIView = {
let content = UIView()
content.translatesAutoresizingMaskIntoConstraints = false
content.backgroundColor = UIColor.blue
return content
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(Scroller)
// Auto layout
Scroller.leftAnchor.constraint(equalTo: view.leftAnchor, constant:0).isActive = true
Scroller.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
Scroller.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0).isActive = true …Run Code Online (Sandbox Code Playgroud) 我试图使这些信息块的大小相同,而不管每个信息的数量.如示例所示,当一个块的文本少于另一个块时,一个块变小,另一个块保持不同的大小.
现在我的问题是,无论内容或图像如何,我如何实现这些块的大小相同?我也将在他们下方使用另一对.

这是CSS代码:
/***********All containers**************/
.bottomContainers{
position: absolute;
margin-left: 0%;
display: inline-box;
}
/**********Small Containers*************/
.container{
max-width: 30%;
max-height: 30%;
margin-top:5%;
margin-bottom: 5%;
margin-left: 10%;
padding-left: 2%;
padding-right: 2%;
padding-bottom: 2%;
background-color: #ecf0f1;
color: grey;
display: inline-block;
/*display: inline-block;*/
border-radius: 5px;
border-bottom: 2px solid grey;
}
Run Code Online (Sandbox Code Playgroud)
这是HTML代码:
<div class="bottomContainers" role="moreInfo">
<!--Small Inner Containers for Information-->
<div class="container" id="firstContainer">
<br />
<center><img src="img/map.png"></center>
<br>
<article>
Some random text is in this block, It doesnt size like the next one
</article>
</div> …Run Code Online (Sandbox Code Playgroud)