Remove border from NSScrollView/NSCollectionView - cocoa

As you can see in the screenshot below, the NSCollectionView I used has some kind of border (the thin gray lines) I want to get rid of. Can somebody tell me how to achieve this? I already tried subclassing the NSCollectionView and tried to overwrite it in the drawRect: by using [[super layer] setBorderWidth:0.0f]; but this did not work.
Searching on Google, SO and the Apple Documentation did not help either. So did anyone achieved this already or knows where I can find an example of how to do it?
Thanks in advance,
Björn

The collectionView is nested in a NSScrollView, which has a borderType property.
You can get rid of the border by simply setting its border type to NSNoBorder.
self.collectionView.enclosingScrollView.borderType = NSNoBorder;

From story board:
Select the scroll view from story board
Then choose no boarder from Attributes Inspector

For Swift 3 :-
collectionView.enclosingScrollView?.borderType = .noBorder

Related

Creating fixed properties in InterfaceBuilder

I want to write a subview which is supposed to have a fixed height. The best would be, that I cannot change it in InterfaceBuilder, because it will be used a lot. If this would work out, it would be an awesome feature for me. But all custom views are freely resizable in InterfaceBuilder in Xcode. How can I achieve this?
A good example is the NSLevelIndicator. Here the height property in the Size Inspector is disabled.
Is there a way to write my own views in such a way that a property is unchangeable? I did a lot of searching but was not lucky in finding something that matched my question.
Thank you in advance
IBOutlet NSLevelIndicator *LED;
NSRect rect = LED.frame;
rect.size.height = 10.0;
[LED setFrame:rect];

Strange NStextfield drawing behaviour

I'm using NSTextField in OSX, why text fields used are inconsistent, Some of them are rectangle perfectly while some of them have corner ? Please see attached screenshot.
I want it to be all square perfectly. I've already checked in IB they seems to have same attributes.
Anyone have ideas?

Multiple NSTableViews selection

I have 2 tableviews in my App which I am using in a similar way to the following screenshot:
My problem is that I want to be able to select items in each list and have the selection remain blue rather than changing to grey when the control loses focus.
I've found that if I overload the AcceptsFirstResponder method of the tableview, I am able keep the grey for selection but this isn't the desired look of the App.
Does anyone have any advice on how I can achieve this? I was thinking I might be able change the grey to a blue whilst keeping the overloading AcceptsFirstResponder method but I'm not sure if this is possible.
Cheers,
Mike
Make sure your NSTableView is view-based, and check out NSTableRowView’s
- (void)drawSelectionInRect:(NSRect)dirtyRect;
BTW, I’m duty-bound to urge you not to do this: the colors have meanings in the UI. That blue color means “if you hit a key (like up arrow), this is the view that’ll receive it.” Your users will be confused.

NSTextField clicked link colour

I have an NSTextField that contains an NSAttributedString which itself contains a clickable link.
I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this?
Seems that I'm not the only one with this problem, and there's a handy class to solve it:
https://github.com/laevandus/NSTextFieldHyperlinks
https://github.com/catlan/DSClickableURLTextField
This (http://developer.apple.com/library/mac/#qa/qa1487/_index.html) may help you. It will show you how to set/change the blue link color and the underlineAttribute. You may also have a look at the methods -linkTextAttributes and -setLinkTextAttributes: of an NSTextView.

Finder like IKImageBrowserCell

I am trying to customize an IKImageBrowserCell to have something close to the Finder.
For the moment my issue is to have a title in 2 lines. Do you have any experience of what need to be modified in order to achieve this?
Thanks and regards,
Yes, this is possible by drawing your title on a CALayer returned from the - (CALayer *)layerForType:(NSString *)type method of a subclassed IKImageBrowserCell.
See my answer here.

Resources