菜鸟教程小白 发表于 2022-12-13 02:44:30

ios - 关闭模态视图后删除模态模糊效果


                                            <p><p>目前我正在使用 MapView 开发一个项目,当用户按下按钮时,它会呈现一个模态视图。</p>

<p>modalView 使用了 iOS 8 典型的 Blur 效果。</p>

<p>问题是,我可以呈现带有模糊效果的模型 View ,并且可以将其关闭,但我无法移除 map 的模糊效果。</p>

<p>当前代码:</p>

<p>ViewController.m</p>

<pre><code>- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSString *buttonTitle = ;
    if() {

      ;

      AlarmViewController *modal = ;
      modal.transitioningDelegate = self;
      modal.modalPresentationStyle = UIModalPresentationOverCurrentContext;
      

-(void)blurEffectMethod {
    UIVisualEffect *blurEffect;
    blurEffect = ;
    UIVisualEffectView *visualEffectView;

    if (_radiusSlider.hidden == NO) {
      visualEffectView = [ initWithEffect:blurEffect];
      visualEffectView.frame = _mapView.bounds;
      ;
      //Hide Bars &amp; Slider
      ;
      [ setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
      _toolBar.hidden = YES ;
      _radiusSlider.hidden= YES;
      _sliderIndicator.hidden = YES;
    }

}
</code></pre>

<p>ModelViewController.m</p>

<pre><code>- (IBAction)dismisModal:(id)sender {
    ;
    ;
}
</code></pre>

<p>如何在关闭 modalView 的同时从 mapView 中删除模糊 SubView?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这就是我设法让模态模糊工作的方法!</p>

<pre><code>let vc = UIViewController()
vc.view = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
vc.modalPresentationStyle = .OverFullScreen

let nc = UINavigationController(rootViewController: vc)
nc.modalPresentationStyle = .OverFullScreen

presentViewController(nc, animated: true, completion: nil)
</code></pre>

<p>这里我在 prepareForSegue 上使用 .OverFullScreen 标志。在我的 viewControllers 上设置了一个模糊 UIVisualEffectView</p>

<pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
    if segue.identifier == &#34;LifeEventSegue&#34; {
      if let nc = segue.destinationViewController as? UINavigationController {
            nc.modalPresentationStyle = .OverFullScreen
            if let vi = nc.viewControllers.first as? UIViewController {
                vi.modalPresentationStyle = .OverFullScreen
            }
      }
    }
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 关闭模态视图后删除模态模糊效果,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/26492871/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/26492871/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 关闭模态视图后删除模态模糊效果