我正在尝试制作一个由4个元素组成的UIView:
4个子视图完美地单独运行,但是这个视图的VFL变得非常困难。视图配置如下:
let frame0View = UIView()
frame0View.translatesAutoresizingMaskIntoConstraints = false
frame0View.backgroundColor = .yellow
frame0View.frame = CGRect(x: 0, y: 0, width: 80, height: 100)
let frame1ScrollView = UIScrollView()
frame1ScrollView.backgroundColor = .cyan
frame1ScrollView.translatesAutoresizingMaskIntoConstraints = false
frame1ScrollView.contentSize = frame1View.bounds.size
和frame2ScrollView和3
相同我的期望是这样的VFL设置,“superview”应该有效:
let mainHorizontalVFL1 = "H:|[FRAME0(80)]-[FRAME1SCROLL(>=200)]-(>=0@500)-|"
let mainHorizontalVFL2 = "H:|[FRAME2SCROLL(80)]-[FRAME3SCROLL(>=200)]-(>=0@500)-|"
let mainVerticalVFL = "V:|[FRAME0(60)]-[FRAME2SCROLL(\(numberOfPlayers*90))]-(>=1@500)-|"
但是这不起作用(FRAME1SCROLL和FRAME3SCROLL根本不可见)。偶然我得到了以下设置工作(自动布局抱怨"无法同时满足约束“正如预期的那样)
let mainHorizontalVFL1 = "H:|[FRAME0(80)]-[FRAME1SCROLL(>=200)]-(>=0@500)-|"
let mainHorizontalVFL2 = "H:|[FRAME2SCROLL(80)]-[FRAME3SCROLL(>=200)]-(>=0@500)-|"
let mainVerticalVFL = "V:|[FRAME0(60)]-[FRAME1SCROLL(60)]-[FRAME2SCROLL(\(numberOfPlayers*90))]-[FRAME3SCROLL(\(numberOfPlayers*90))]-(>=0@500)-|"
此设置目前有效,但我无法使用预期的设置,这有点烦人。任何人都知道要找什么来解决这个问题?