In the documentation:
Returns the size of the view that satisfies the constraints that it has.
OK, I create a view in a storyboard and add restrictions:
yellowview.leading = self.view.leading
yellow view.trailing = self.view.trailing
yellow view.bottom = self.view.bottom
yelloview.height = 128

Now I print systemLayoutSizeFittingSize, which I expect as width UIScreenand 128 height. but the result:
(0.0, 128.0)
(10000.0, 128.0)
========================================
Then I create a view and add a restriction for it through the code:
let btn :UIButton = {
let btn = UIButton(type: .Custom)
btn.backgroundColor = UIColor.redColor()
btn.translatesAutoresizingMaskIntoConstraints = false
return btn
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(btn)
btn.leadingAnchor.constraintEqualToAnchor(self.view.leadingAnchor, constant: 100).active = true
btn.trailingAnchor.constraintEqualToAnchor(self.view.trailingAnchor, constant: -100).active = true
btn.topAnchor.constraintEqualToAnchor(self.view.topAnchor, constant: 100).active = true
btn.bottomAnchor.constraintEqualToAnchor(self.view.bottomAnchor, constant: -100).active = true
}
He shows well:

Now print it systemLayoutSizeFittingSize:
(30.0, 34.0)
(30.0, 34.0)
Which I expect to be UIScreensize: 100.
Why am I getting these strange values? Or do I not understand the document?
source
share