Reputation: 523
I'm trying to set up a view inside a container view. It has to be done this way due to several different controllers for the views inside the swipeView
.
@IBOutlet weak var containerView: ContainerView!
override func viewDidLoad() {
super.viewDidLoad()
//Some other stuff
//Create new swipeView
var swipeView = MDCSwipeToChooseView(frame: containerView.frame, options: options)
//Add the view from the controller to the swipeView
swipeView.addSubview(containerViewController.view)
//Add the swipeView to the main view
self.view.addSubview(swipeView)
I end up with this
The white area is the view that should inherit containerView
's size. The containerView
is the pink one in the background and it's shown properly. I have noticed that containerView.frame
returns the size of the component from the storyboard, see pic 2. The frame obtained by calling on the containerView.frame
is the one before the view is resized to meet all constrains. How do i get the proper values?
Upvotes: 3
Views: 2577
Reputation: 523
Placing the same code inside viewDidLayoutSubviews()
instead of viewDidLoad()
solved the issue.
Upvotes: 1