In the above view, viewB is a subview of viewA created using an xib and the constrains also added in the xib. viewB has constrains top, bottom, leading & trailing relative to its superview. The file owner is swift view controller. viewB is connected with the file owner
@IBOutlet weak var viewB: UIView!
The issue is resolved. It was related to size classes in the XIB. One constraint was added to Cw & Rh sizes. If anyone come across this issue, check the xib's layout constrains twice :)