Search code examples
objective-cios8uiblureffect

No known class method for selector notificationCenterVibrancyEffect iOS 8


I'm trying out UIBlurEffect and UIVibrancyEffect for a view.

Apple docs here claim a "notificationCenterVibrancyEffect", but even after importing UIKit in my class, it throws No known class method for selector notificationCenterVibrancyEffect.

Code looks like this, every other class method resolves just fine:

UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect notificationCenterVibrancyEffect];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];

Solution

  • This is only available for "Today" extensions. If you create a new target in your project of the class "Today" extensions and you add your code to the view controller, it will build fine.

    The method + (UIVibrancyEffect *)notificationCenterVibrancyEffect; is declared in a category of the class UIVibrancyEffect named NotificationCenter, and declared in the NotificationCenter framework, in a header file called NCWidgetProviding.h

    Try: #import <NotificationCenter/NotificationCenter.h> in your view controller, I was able to build a sample project with your code this way.