I’m on a new project in Xcode.
I’dt like to add a blur effect behind the main window.
After a couple of hours spent on it, I found this Swift snippet on Github but I’m not able to convert it to AppleScriptObjC.
Can someone help me on this?
//
// AppDelegate.swift
// Swift Window Blur
//
// Created by Lee Brimelow on 6/3/14.
// Copyright (c) 2014 Lee Brimelow. All rights reserved.
//
import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var window: NSWindow
// define the visual effect view
var blurryView = NSVisualEffectView(frame: NSRect(x: 0, y: 0, width: 800, height: 600))
func applicationDidFinishLaunching(aNotification: NSNotification?) {
// this is default value but is here for clarity
blurryView.blendingMode = NSVisualEffectBlendingMode.BehindWindow
// set the background to always be the dark blur
blurryView.material = NSVisualEffectMaterial.Dark
// set it to always be blurry regardless of window state
blurryView.state = NSVisualEffectState.Active
self.window.contentView.addSubview(blurryView)c
}
func applicationWillTerminate(aNotification: NSNotification?) {
// Insert code here to tear down your application
}
}
Why do it in code? Just drag a Visual Effect View into the .xib view and set its properties in the Attributes inspector. Position it so that it’s a subview of the window’s content view, and the rest of the items are subviews of it.
Really, I don’t understand.
Here are my settings for the Attributes inspector.
But the window stays opaque if I don’t set the window’s alphaValue.
If I do, the window is transparent but there’s no blur effect.
I suspect you’re looking for more effect than it provides – it’s meant to be a very subtle appearance. You shouldn’t be giving it a Core Animation Layer or fiddling with its alpha – it’s meant to be self-contained.