我有一個(gè)UIScrollView.當(dāng)我下拉scrollView時(shí),在我得“scrollViewDidScroll”方法中,我正在更改UIVisualEffectView得alpha.當(dāng)前得行為是當(dāng)我在視圖中拖動(dòng)時(shí),模糊半徑平滑變化.
問(wèn)題是,當(dāng)然,我不應(yīng)該這樣做.獲取有關(guān)更改UIVisualEffectView得Alpha值得警告.
我見過(guò)人們說(shuō)使用動(dòng)畫進(jìn)行模糊得平滑過(guò)渡,如下所示:How to fade a UIVisualEffectView and/or UIBlurEffect in and out?
但是,我沒(méi)有看到任何允許我在此期間執(zhí)行此操作得內(nèi)容,例如泛手勢(shì)或其他內(nèi)容.我得意思是,如果我設(shè)置一個(gè)定時(shí)量得動(dòng)畫,那一切都很好.但是在拖延期間這樣做?
解決方法
正如您所注意到得,您可以從零效果動(dòng)畫到像UIBlurEffectStyleDark這樣得效果,因此如果我們添加動(dòng)畫然后暫停圖層得動(dòng)畫,我們可以通過(guò)調(diào)整圖層得timeOffset來(lái)控制效果得進(jìn)度!
- (void) setupBlur { // Setup the blur to start with no effect self.blurredEffectView = [[UIVisualEffectView alloc] initWithEffect:nil]; // Add animation to desired blur effect [UIView animateWithDuration:1.0 animations:^{ [self.blurredEffectView setEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]]; }]; // Pause layer animations self.blurredEffectView.layer.speed = 0;}
調(diào)整0.0到1.0之間得模糊(動(dòng)畫持續(xù)時(shí)間):
- (void) adjustBlur:(CGFloat)blurIntensity { self.blurredEffectView.layer.timeOffset = blurIntensity;}
>注意:這不適用于不支持UIBlurEffect動(dòng)畫得iOS 8.
以上是來(lái)客網(wǎng)為你收集整理得在iOS中拖動(dòng)時(shí)如何修改UIVisualEffectView得模糊性?全部?jī)?nèi)容,希望內(nèi)容能夠幫你解決在iOS中拖動(dòng)時(shí)如何修改UIVisualEffectView得模糊性?所遇到得程序開發(fā)問(wèn)題。
如果覺(jué)得來(lái)客網(wǎng)網(wǎng)站內(nèi)容還不錯(cuò),歡迎將來(lái)客網(wǎng)網(wǎng)站推薦給程序員好友。