I use visual format to layout subviews in cell like this:
contentView.addSubview(accountLabel)
contentView.addSubview(contentLabel)
contentView.addSubview(timeLabel)
let views: [String : Any] = [
"accountLabel": accountLabel,
"contentLabel": contentLabel,
"timeLabel": timeLabel
]
let hConstraint1 = NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[accountLabel]-[timeLabel]-8-|", options: [.alignAllCenterY], metrics: nil, views: views)
let hConstraint2 = NSLayoutConstraint.constraints(withVisualFormat: "H:[contentLabel]-8-|", options: [], metrics: nil, views: views)
let vConstraint = NSLayoutConstraint.constraints(withVisualFormat: "V:|-12-[accountLabel]-8-[contentLabel]-12-|", options: [.alignAllLeading], metrics: nil, views: views)
NSLayoutConstraint.activate(hConstraint1+hConstraint2+vConstraint)
And it looks ok when run in simulator:
However, some layout issues occur when debugging view hierarchy:
Why these layout issues occur while the runtime UI looks ok?
Is something wrong with the visual format string above? Or it's the bug of Xcode?
How to remove these layout issues?