Background color on NSView?


Dave
 

Hi All,

I’ve just realised that NSView don’t have a background colour. I remember hitting this a long while ago and got around it by using a layer and adding a “setBackgroundColor” method to my Class.

Does anyone know how to do this? I can’t find the code or a reference to it now.

All the Best
Dave

PS

As you may have gathered I’m porting code between iOS and Mac and Vice Versa, if anyone else is doing this kind of thing, I’ve found the following Macro’s VERY handy:


#if TARGET_OS_IPHONE

#define LTWPlatformKitHeaderFile <UIKit/UIKit.h>

#define LTWNativeViewControllerClass UIViewController
#define LTWNativeViewClass UIView
#define LTWNativeImageClass UIImage
#define LTWNativeImageViewClass UIImageView
#define LTWNativeColorClass UIColor
#define LTWNativeBezierClass UIBezierPath

#define LTWNativeViewIdentifierMethod accessibilityIdentifier

#define LTWNativePointType CGPoint
#define LTWNativeSizeType CGSize
#define LTWNativeRectType CGRect

#elif TARGET_OS_OSX

#define LTWPlatformKitHeaderFile <AppKit/AppKit.h>

#define LTWNativeViewControllerClass NSViewController
#define LTWNativeViewClass NSView
#define LTWNativeImageClass NSImage
#define LTWNativeImageViewClass NSImageView
#define LTWNativeColorClass NSColor
#define LTWNativeBezierClass NSBezierPath

#define LTWNativeViewIdentifierMethod identifier

#define LTWNativePointType NSPoint
#define LTWNativeSizeType NSSize
#define LTWNativeRectType NSRect


#else

#error !!!!!NO PLATFORM SPECIFIED!!!!

#endif

Join cocoa@apple-dev.groups.io to automatically receive all group messages.