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.
.
Solved. By adding subviews to visualEffectView instead of self.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.