1

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

Community
  • 1
  • 1
Pim
  • 393
  • 3
  • 18

2 Answers2

1

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]];
Community
  • 1
  • 1
Heinrich Giesen
  • 501
  • 1
  • 3
  • 11
0

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

abanet
  • 1,327
  • 17
  • 22
  • Currently using 7.0.1. Writing for OS X, not for iOS. – Pim Oct 22 '15 at 14:20
  • The class is NSView. Is there a way this has something to do with the core graphics framework? I can't add a reference to the UIKit for example, so using UIColor won't work. – Pim Oct 22 '15 at 14:28
  • 1
    ah! ok, then it seems to be not so easy... may be this video can help you! https://www.youtube.com/watch?v=K8eWIZ39W4A – abanet Oct 22 '15 at 14:31