I am currently trying to create my own app on IOS with Swift and Xcode. Everything was pretty good so far except one small thing.
To sum up, I have a UIViewController which contains a NavBar and three ContainerViews ones above the others (they take all the space left by the NavBar, therefore the biggest part of the screen). When I select a tab via a menu, all the containers disappear except the one I have choosen. I managed to add a gradient background on my precedent views but for all the containers, the background is visible but there is a tiny margin on the right side of the screen.
Of course, I put all the constraints needed for the background view in order to make it fit all the screen.
Here is my code for the gradient :
let gradientLayer = CAGradientLayer()
gradientLayer.frame = self.view.bounds
let topColor = UIColor(red:0.12, green:0.34, blue:0.60, alpha:1.0).CGColor as CGColorRef;
let bottomColor = UIColor(red:0.49, green:0.73, blue:0.91, alpha:1.0).CGColor as CGColorRef;
gradientLayer.colors = [topColor,bottomColor]
gradientLayer.locations = [0, 1.0]
self.accueilContainer.layer.addSublayer(gradientLayer)
And here is the result I get :
http://www.image-heberg.fr/files/147261739553.png
You can see the little white space on the right side and I don't know how to remove it..
NOTE : This gradient code works perfectly with other Views (no margins)
Thank you for your help
Make sure your background view has a trailing constraint to the super view trailing edge. Make sure the constraint is NOT set "Relative to the margin".