NSSlider without background - cocoa

When ever my NSSlider is displayed, it has a rounded rectangle background (see the linked image). I would like it to only have the bar and the knob drawn, not this background.
I have looked into subclassing NSSliderCell or NSSlider, but it seem that no matter what draw method I override this background will not go away. Is there anything I can do to get rid of this background, or are my only option to make my own control?
Thank you
Søren

Uncheck the Bordered option in Xcode or you can set it to NO in code.
If that doesn't work you've got it inside an NSBox or something

Related

NSTextView doesn’t work when placed near the top of an NSWindow

Context
I have a window with a fullSizeContentView and a transparent titlebar and hidden titlebar.
I don’t even want the titlebar, but I had to enable it to get rounded corners on the NSWindow.
Problem
An NSTextView, when placed near the top edge, doesn’t react to any clicks. It doesn‘t let me select any text, and doesn’t let me click links I added via NSAttributedString.
This issue disappears when I disable the titlebar altogether.
Any Help would be greatly appreciated. Thanks!
Big Context
I’m trying to implement little “in-app notifications” that show peripheral status updates. I considered using NSAlert but I don’t want to prevent the user from interacting with the rest of the interface while the notifications are showing, so I decided to implement it myself.
The notifications are little, non-movable windows without a titlebar. They are basically just grey rectangles with rounded corners and a shadow that draw inside the main application window and contain one or a few lines of text. The first line of text is almost entirely behind the invisible titlebar which is why I’m having issues.
The only thing I need the notifications to do besides display text is link to webpages that contain more info about a notification’s message.
I feel like I might be approaching this wrong. If you have any suggestions or ideas on how to solve the problem, I’m eager to hear them. Thanks!
I finally figured it out!
I nailed it down to the contentInsets of the NSScrollView. (which your are for some reason forced to have around your NSTextView when creating it in Interface Builder)
The contentInsets were automatically being set to account for the invisible titlebar, even though the docs say that NSScrollView - automaticallyAdjustsContentInsets (which is set to YES by default and which I assume was causing this) doesn't do automatic insets for transparent titlebars.
After programmatically setting the scrollView's contentInsets to 0, everything works great!
In Objective C, you can set your scrollView's contentInsets to 0 like this:
NSScrollView *scrollView = (NSScrollView *)self.textView.superview.superview;
scrollView.automaticallyAdjustsContentInsets = NO; // Doesn't remove insets // Probably calling this too late
scrollView.contentInsets = NSEdgeInsetsMake(0, 0, 0, 0);
Here's a working example.
Hope this helps!

Opt-out borderless NSButton from NSVisualEffectView vibrancy

I have a NSVisualEffectView with vibrancy containing text fields (NSTextField or NSComboBox) and borderless buttons. The buttons are positioned over the text fields and I want to disable the vibrancy effect on the borderless buttons since they're supposed to appear on the white background of the text fields.
What I tried doing, as per recommendation in the NSVisualEffectView class reference, is to wrap my NSButton inside another NSVisualEffectView with its state set to Inactive. What this does is it replaces the "vibrant" background by a light grey background.
The picture below illustrates this. The first field is my attempted solution, the second shows the default behavior of a borderless button as child of a NSVisualEffectView.
I also tried subclassing the NSButton and set its cell background color to white or clear but I always get the grey background.
How can I change the light grey background to a white or clear background?
Thanks
I managed to solve this myself after a few hours of headache. The solution doesn't need the button to be wrapped in a NSVisualEffectView. Simply subclassing NSButton and overriding the allowsVibrancy property and setting it to false was enough.
In Swift:
override var allowsVibrancy: Bool { return false }

Replace IKImageBrowserView's Superclass with NSVisualEffectView

I looking to make my IKImageBrowserView's background have a blurred background. According to the Apple Documentation, the IKImageBrowserView is based upon NSView. Is it possible to make an IKImageBrowserView inherit from an NSVisualEffectView instead so that I can give the background a blurred look. I assume that to start I must subclass the IKImageView, but I am unsure of where to go next. Could someone please point me in the right direction?
Thanks
Add the IKImageBrowserView as a subview for an NSVisualEffectsView and make sure the browser view doesn't draw it's background.
The visual effects views are intended to be used in this way, not through class inheritance.

Why does this textured NSWindow suddenly change its background gradient when resizing?

Can someone please tell me, why the background gradient of the textured NSWindow in this app suddenly changes, when you make the window a little bit smaller?
This is the minimal example I could find, that exhibits this behaviour. App & Source are available via Dropbox.
-- Updates:
If you put the slider lower,the gradient does not change when resizing the window:
Also, the change seems to happen when the distance between the slider and the window's right border gets smaller than the HIG says it should be.
It is really interesting question =)
I don't shure, but guess, this problem is connected to layers displaying.
If you still want to use textured window, you can put additional NSView object in the interface builder between NSView and NSSlider (NSWindow -> NSView -> NSView -> NSSlider). It fixes the bug.

NSWindow textured gradient fill weirdness

Hey, I've got a textured NSWindow, and I'm seeing some strange behaviour with the way it gets textured. If I have an IKImageBrowserView in the window, then there is a full light to dark gradient in both the title bar and the bottom bar of the window, but if I hide the IKImageBrowserView and show my NSBox, then the gradient starts light in the top, and ends dark in the bottom bar. I think screenshots may describe the problem more accurately.
Alternatively, is there a way of placing an NSTextField and an NSProgressIndicator overtop of an ikimagebrowserview? They aren't visible when placed above the ikimagebrowserview for some reason.
I experienced a similar issue with inconsistent NSWindow textured/metallic gradients.
My findings, and a solution which will work for the above issue may be found in the responses to the following post:
NSWindow textured background with NStextField

Resources