在我的项目中,我以编程方式在堆栈视图中添加视图。我需要的是,无论何时添加新视图,都要增加堆栈视图的大小。并根据堆栈视图的新高度,移动其他项目以避免所有视图的交叉。
但是,这就是:http://imgur.com/a/BnPvl
视图和不同的按钮应该是波纹管堆栈视图。我怎么做?提前谢谢。
let label = UILabel(frame: CGRectMake(0, 0, cell.frame.width, 100))
let label2 = UILabel(frame: CGRectMake(0, 100, cell.frame.width, 100))
let label3 = UILabel(frame: CGRectMake(0, 200, cell.frame.width, 100))
label.text = "Label"
label2.text = "I am a test content."
label3.text = "I am a longer test content but not that long, just enough to make 2 lines maybe"
cell.mystack.addSubview(label)
cell.mystack.addSubview(label2)
cell.mystack.addSubview(label3)
cell.mystack.frame = CGRectMake(0, 0, cell.mystack.frame.width, 300)