Auto Layout constraints issue in iOS 12.1

My application has a 'Search Bar' inside a

UIView
named as 'Container for Search Bar' which is again placed under a Navigation Bar. On the
Interface Builder
auto layout
constraints
are set between the search bar and
UIView
as shown below:
  1. First Item: Search Bar.Top Relation: Equal Second Item: Container for Search Bar.Top Constant: 0 Priority: 1000 Multiplier: 1
  2. First Item: Search Bar.Leading Relation: Equal Second Item: Container for SearchBar.Leading Constant: 0 Priority: 1000 Multiplier: 1
  3. First Item: Search Bar.Trailing Relation: Equal Second Item: Container for SearchBar.Trailing Constant: 0 Priority: 1000 Multiplier: 1

The 'Container for Search Bar' (UIView) is set with width: 480 and Height: 44. Autoresizing for

UIView
is set to stretch and position relatively in all directions. The search bar is also set with width: 480.


The UIView container is placed between back/forward buttons inside navigation bar. That's the reason the UIView container is set with 'Auto-Resizing' instead of setting auto layout constraints. As it is between two button items I think it can't be set with leading & trailing space constraints to its parent


Until IOS 10 the

UIView
and Search Bar stretched relatively based on the screen resolution of the device. However for IOS 12.1 version 'Search bar' becomes invisible at runtime. When I have debugged and checked the sizes, widths of both
UIView
and its child 'Search Bar' are set to 0 at runtime. When auto-layout constraints are removed then only the search bar is visible but not stretching according to screen resolution.


Need help in solving this problem.