Gintaras
Gintaras

Reputation: 224

Making Spotlight Search Bar like view in Objc/Swift

I'm trying to replicate spotlight's view behaviour. Have added blurred adaptive background to NSWindow using:

NSVisualEffectView *visualEffectView =  [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
[visualEffectView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
visualEffectView.material = NSVisualEffectMaterialMediumLight;
visualEffectView.blendingMode = NSVisualEffectBlendingModeBehindWindow;
visualEffectView.wantsLayer = true;
visualEffectView.state = NSVisualEffectStateActive;
visualEffectView.layer.cornerRadius = 7.5;
[self addSubview:visualEffectView];

The problem is that background does work, but text and other elements inside the window don't adapt to the background below window correctly.

Here is the image.

attached.

Upvotes: 2

Views: 227

Answers (1)

Gintaras
Gintaras

Reputation: 224

Solved. By adding subviews to visualEffectView instead of self.

Upvotes: 2

Related Questions