Pim
Pim

Reputation: 433

Changing backgroundcolor of a view seems hard?

I want to change the background color of a view within the view controller. Selecting the view and opening the attributes inspector isn't showing that much. Should have an option here for the background.

enter image description here

Tried coding it within the (void)viewDidLoad{} with: self.view.backgroundColor = [NSColor blueColor]; That isn't working either, no object of NSView.

What am I doing wrong? I read that the coding problem probably has something to with the newer version of Xcode. coding issue

Upvotes: 1

Views: 403

Answers (2)

Heinrich Giesen
Heinrich Giesen

Reputation: 521

This is already questioned and answered in Best way to change the background color for an NSView

Here the code for OS X

[self.view setWantsLayer:YES];
[self.view.layer setBackgroundColor:[[NSColor whiteColor] CGColor]];

Upvotes: 1

abanet
abanet

Reputation: 1387

wich xcode version are you using? This is how I change the backgroun color using the attributes inspector in Version 7.1 (7B91b) enter image description here

Upvotes: 0

Related Questions