Since ios 8.0 views have additional layoutMargins
which by default has an 8 points values for every side.
When I try to change margins in viewDidL
You are trying to set the layout margin of a root view of a view controller. The root view behaves differently than any other view in the hierarchy in regard of the layout margins.
Layout margins of a root view are managed exclusively by the view controller, you can not set them.
From Apple documentation:
If the view is a view controller’s root view, the system sets and manages the margins. The top and bottom margins are set to zero points. The side margins vary depending on the current size class, but can be either 16 or 20 points. You cannot change these margins.
https://developer.apple.com/reference/uikit/uiview/1622566-layoutmargins