如何在通知中心(iOS 8)中复制模糊文本 [英] How to replicate the blurred text in Notification Center (iOS 8)

查看:184
本文介绍了如何在通知中心(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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆