在页面视图控制器中淡入翻页对象

Fade in object on page turn in Page View Controller

我试图在页面进入 PageViewController 时淡出 UI模糊背景。

例如,第 1 页的背景没有 UI 模糊,但我希望第 2 页在页面出现时在控制器的背景上淡化深色模糊。

当前发生的是页面出现,半秒后应用模糊。

这是我当前第 2 页的内容:

    @IBOutlet weak var blurEffect: UIVisualEffectView!


        override func viewDidLoad() {
            super.viewDidLoad()
            let overlay = blurEffect
            overlay.effect = nil
        }

        override func viewDidAppear(animated: Bool) {
            let overlay = blurEffect
            overlay.effect = nil
            UIView.animateWithDuration(0.5) {
                overlay.effect = UIBlurEffect(style: .Dark)
            }
        }

The following properties of the UIView class are animatable:

@property frame

@property bounds

@property center

@property transform

@property alpha

@property backgroundColor

@property contentStretch

Apple documentation

不清楚您真正想要什么,但是如果您想在另一个视图控制器上呈现一个视图控制器,您正在模糊呈现视图控制器作为呈现视图控制器的背景。你应该:

  1. 正在将呈现的视图控制器的视图背景颜色更改为清除颜色。
  2. 在呈现的视图控制器的视图层次结构的底部添加 UIVisualEffectView。
  3. 将转场更改为模态转场或以模态方式呈现视图控制器。
  4. 将 segue 的呈现样式更改为当前上下文或设置呈现的视图控制器的呈现方式 viewController.modalPresentationStyle = .OverCurrentContext
  5. 将过渡更改为交叉叠化或垂直覆盖 viewController.modalTransitionStyle = .CoverVertical

我相信您也可以在其他方面应用此技术,尽管它的性能很昂贵。