Reputation: 68240
I would like to have the NSTextView background and the window itself of TextEdit transparent but I'm not really sure how to do this. Some hints would be great.
Upvotes: 2
Views: 2044
Reputation: 23
You need exactly two lines of code to achieve this:
[textField setBordered:NO];
[textField setDrawsBackground:NO];
Upvotes: 1
Reputation: 7272
Easy! The text view is created programmatically in the DocumentWindowController class, so just find the points where it is created (in the methods setHasMultiplePages: and addPage) and simply insert the code:
[textView setDrawsBackground:NO];
...to prevent the textView from drawing it's default white background. The light gray color you then see is being drawn by the text view's enclosing scrollview, which you can change in the DocumentWindow NIB.
EDIT: If you don't want the Scroll View to draw its background, uncheck "Draws Background," at which point you will just see the window's default gray background (drawn by it's content view)
Upvotes: 3
Reputation: 68240
This code seems to work:
[[self firstTextView] setDrawsBackground:NO];
[scrollView setDrawsBackground:NO];
[[self window] setBackgroundColor: [NSColor clearColor]];
[[self window] setOpaque:NO];
Upvotes: 1