The problem is that you’re getting the view’s bounds before it’s been resized for the current device. It’s larger than it will be later when it appears on screen, so the right side of your rounded rect is off the right side of the screen.
You need to create path
and set maskLayer.path
later, after the view has been resized, which means during or after the layout phase of the run loop. So either subclass the view and do it in the view’s layoutSubviews
method, or do it in the view controller’s viewDidLayoutSubviews
method.