如何在通知中心(iOS 8)中复制模糊文本 [英] How to replicate the blurred text in Notification Center (iOS 8)
问题描述
我在iOS 8中使用TodayExtension,我想知道如何将模糊效果应用于文本或按钮。我已经发现它与UIVisualEffectView有关。但我不知道如何使用它。
I am playing with TodayExtension in iOS 8 and I wondered how to apply that blur effect to the Text or to buttons. I already figured out that it has something to do with UIVisualEffectView. But I don't know how to use it.
我正在使用Objective-C
I am using Objective-C
任何人都可以解释它对我来说如何实现这个目标?
Can anyone explain it to me how to achieve this?
谢谢,大卫
推荐答案
更新适用于iOS 10的答案
在iOS 10中,您可以使用 widgetPrimaryVibrancyEffect
和 widgetSecondaryVibrancyEffect
自动返回 UIVibrancyEffect
对象。
In iOS 10, you can use widgetPrimaryVibrancyEffect
and widgetSecondaryVibrancyEffect
to automatically return a UIVibrancyEffect
object.
iOS 9答案
使用此代码将振动效果应用于整个小部件:
Use this code to apply a vibrancy effect to your whole widget:
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:[UIVibrancyEffect notificationCenterVibrancyEffect]];
effectView.frame = self.view.bounds
effectView.autoresizingMask = self.view.autoresizingMask;
__strong UIView *oldView = self.view;
self.view = effectView;
[effectView.contentView addSubview:oldView];
self.view.tintColor = [UIColor clearColor];
这篇关于如何在通知中心(iOS 8)中复制模糊文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!