Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述因此,当您在主屏幕上向下滚动时,我正在使用新的UIViewPropertyAnimator和UIVisualEffectView来实现与Spotlight搜索相同的功能,并使背景模糊. 我正在使用fractionComplete属性来设置平移UIView时要模糊多少的过程. animator = UIViewPropertyAnimator(duration: 1, curve: .linear) 因此,当您在主屏幕上向下滚动时,我正在使用新的UIVIEwPropertyAnimator和UIVisualEffectVIEw来实现与Spotlight搜索相同的功能,并使背景模糊.

我正在使用fractionComplete属性来设置平移UIVIEw时要模糊多少的过程.

animator = UIVIEwPropertyAnimator(duration: 1,curve: .linear) {        self.blurEffectVIEw.effect = nil    }

并且模糊度的变化值在0.0-1.0之间.

animator?.fractionComplete = blurValue

但是当我取消平移手势时,我希望模糊从其所处的位置动画回到无模糊(例如,〜> 1.0),持续时间为0.4毫秒.

现在我只是在取消平移手势时将fractionComplete设置为1.0.相反,我想要动画它.
我已经尝试了UIVIEw.animate(withDuration ..但它不会影响UIVIEwPropertyAnimators fractionComplete,这是模糊UIVisualEffectVIEw的唯一方法.

有任何想法吗?

解决方法 似乎fractionComplete有一个BUG(我在Stackoverflow上的问题: UIViewPropertyAnimator does not update the view when expected),rdar://30856746.该属性只将状态从非活动状态设置为活动状态,但不更新视图,因为(我假设)还有另一个内部状态不会触发.

要解决此问题,您可以执行以下 *** 作:

animator.startAnimation() // This will change the `state` from inactive to activeanimator.pauseAnimation() // This will change `isRunning` back to false,but the `state` will remain as active// Now any call of `fractionComplete` should update your vIEw correctly!animator.fractionComplete = /* your value here */

这是一个可以玩的游乐场片段:

let liveVIEw = UIVIEw(frame: CGRect(x: 0,y: 0,wIDth: 400,height: 50))liveVIEw.backgroundcolor = .whitePlaygroundPage.current.needsIndefiniteExecution = truePlaygroundPage.current.liveVIEw = liveVIEwlet square = UIVIEw(frame: CGRect(x: 0,wIDth: 50,height: 50))square.backgroundcolor = .redliveVIEw.addSubvIEw(square)let animator = UIVIEwPropertyAnimator.init(duration: 5,curve: .linear)animator.addAnimations {    square.frame.origin.x = 350}let blurVIEw = UIVisualEffectVIEw(effect: UIBlurEffect(style: .dark))blurVIEw.frame = liveVIEw.boundsliveVIEw.addSubvIEw(blurVIEw)animator.addAnimations {    blurVIEw.effect = nil}// If you want to restore the blur after it was animated,you have to // safe a reference to the effect which is manipulatedlet effect = blurVIEw.effectanimator.addCompletion {    // In case you want to restore the blur effect    if [+++] == .start { blurVIEw.effect = effect }}animator.startAnimation()animator.pauseAnimation()dispatchQueue.main.asyncAfter(deadline: .Now() + 2) {    animator.fractionComplete = 0.5}dispatchQueue.main.asyncAfter(deadline: .Now() + 4) {    // decIDe the direction you want your animation to go.    // animator.isReversed = true    animator.startAnimation()}
总结

以上是内存溢出为你收集整理的swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景全部内容,希望文章能够帮你解决swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景_app_内存溢出

swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景

swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景,第1张

概述因此,当您在主屏幕上向下滚动时,我正在使用新的UIViewPropertyAnimator和UIVisualEffectView来实现与Spotlight搜索相同的功能,并使背景模糊. 我正在使用fractionComplete属性来设置平移UIView时要模糊多少的过程. animator = UIViewPropertyAnimator(duration: 1, curve: .linear) 因此,当您在主屏幕上向下滚动时,我正在使用新的UIVIEwPropertyAnimator和UIVisualEffectVIEw来实现与Spotlight搜索相同的功能,并使背景模糊.

我正在使用fractionComplete属性来设置平移UIVIEw时要模糊多少的过程.

animator = UIVIEwPropertyAnimator(duration: 1,curve: .linear) {        self.blurEffectVIEw.effect = nil    }

并且模糊度的变化值在0.0-1.0之间.

animator?.fractionComplete = blurValue

但是当我取消平移手势时,我希望模糊从其所处的位置动画回到无模糊(例如,〜> 1.0),持续时间为0.4毫秒.

现在我只是在取消平移手势时将fractionComplete设置为1.0.相反,我想要动画它.
我已经尝试了UIVIEw.animate(withDuration ..但它不会影响UIVIEwPropertyAnimators fractionComplete,这是模糊UIVisualEffectVIEw的唯一方法.

有任何想法吗?

解决方法 似乎fractionComplete有一个BUG(我在Stackoverflow上的问题: UIViewPropertyAnimator does not update the view when expected),rdar://30856746.该属性只将状态从非活动状态设置为活动状态,但不更新视图,因为(我假设)还有另一个内部状态不会触发.

要解决此问题,您可以执行以下 *** 作:

animator.startAnimation() // This will change the `state` from inactive to activeanimator.pauseAnimation() // This will change `isRunning` back to false,but the `state` will remain as active// Now any call of `fractionComplete` should update your vIEw correctly!animator.fractionComplete = /* your value here */

这是一个可以玩的游乐场片段:

let liveVIEw = UIVIEw(frame: CGRect(x: 0,y: 0,wIDth: 400,height: 50))liveVIEw.backgroundcolor = .whitePlaygroundPage.current.needsIndefiniteExecution = truePlaygroundPage.current.liveVIEw = liveVIEwlet square = UIVIEw(frame: CGRect(x: 0,wIDth: 50,height: 50))square.backgroundcolor = .redliveVIEw.addSubvIEw(square)let animator = UIVIEwPropertyAnimator.init(duration: 5,curve: .linear)animator.addAnimations {    square.frame.origin.x = 350}let blurVIEw = UIVisualEffectVIEw(effect: UIBlurEffect(style: .dark))blurVIEw.frame = liveVIEw.boundsliveVIEw.addSubvIEw(blurVIEw)animator.addAnimations {    blurVIEw.effect = nil}// If you want to restore the blur after it was animated,you have to // safe a reference to the effect which is manipulatedlet effect = blurVIEw.effectanimator.addCompletion {    // In case you want to restore the blur effect    if  == .start { blurVIEw.effect = effect }}animator.startAnimation()animator.pauseAnimation()dispatchQueue.main.asyncAfter(deadline: .Now() + 2) {    animator.fractionComplete = 0.5}dispatchQueue.main.asyncAfter(deadline: .Now() + 4) {    // decIDe the direction you want your animation to go.    // animator.isReversed = true    animator.startAnimation()}
总结

以上是内存溢出为你收集整理的swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景全部内容,希望文章能够帮你解决swift – 为UIViewPropertyAnimator的fractionComplete设置动画以模糊背景所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1012882.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存