Swift UIViewReportBrokenSuperviewChain cause by Layer manipulation : <p>I run into a problem after migrating my code to Swift 3.
I guess iOS10 raises new issues now and it's actually not related to Swift itself.</p>

<p>The error:</p>

<pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View has lost track of its superview, most likely through unsupported use of CALayer API on the view's layer. If this isn't a crash yet, it will be in the near future. 
    Problem view: &lt;UIToolbar: 0x102552d80; frame = (0 0; 375 683); alpha = 0.97; opaque = NO; layer = &lt;CALayer: 0x1700383e0&gt;&gt;
    Expected parent: &lt;MyModelView: 0x10250ecd0; frame = (0 -16; 375 683); hidden = YES; layer = &lt;CALayer: 0x17003d4a0&gt;&gt;
Break on UIViewReportBrokenSuperviewChain to debug.'
</code></pre>

<p>The code triggering the issue is :</p>

<pre><code>[c presentViewController:tabBarViewController animated:NO completion:^{
</code></pre>

<p>The sub code responsible for the problem seems to be:</p>

<pre><code>- (void)addBlurView
{
  CGRect viewBounds = [[UIScreen mainScreen]applicationFrame];
  self.myModelView = [[MyModalView alloc] initWithFrame:CGRectMake(viewBounds.origin.x, -16, viewBounds.size.width, viewBounds.size.height+36)];

  if(![self toolbar]) {
    _toolbar = [[UIToolbar alloc] initWithFrame:[self.myModelView bounds]];
    [_toolbar setBarStyle:UIBarStyleBlack];
    _toolbar.alpha = 0.97;
    [self.myModelView.layer insertSublayer:_toolbar.layer atIndex:0];
  }

  [self.view addSubview:self.myModelView];
}
</code></pre>
