ColorTools - Tools for color management in Mac OS X and iOS, supporting Adobe Swatch Exchange and NSColorList formats
Tools for color management in Mac OS X and iOS, supporting Adobe Swatch Exchange and NSColorList formats


#dc comics#batman#dc#batfam#bruce wayne#dick grayson#batfamily#tim drake#dc fanart




seen from Germany
seen from Canada
seen from United States
seen from United States
seen from United States
seen from United States

seen from China

seen from United States
seen from Algeria

seen from United States

seen from United Kingdom
seen from Argentina
seen from United States

seen from Malaysia

seen from United States

seen from Netherlands
seen from Mexico
seen from Argentina
seen from Belarus
seen from Japan
ColorTools - Tools for color management in Mac OS X and iOS, supporting Adobe Swatch Exchange and NSColorList formats
Tools for color management in Mac OS X and iOS, supporting Adobe Swatch Exchange and NSColorList formats
Converting an NSColor to a CGColor
Here's an easy way to convert an NSColor to a CGColor:
- (CGColorRef)NSColorToCGColor:(NSColor *)color { NSInteger numberOfComponents = [color numberOfComponents]; CGFloat components[numberOfComponents]; CGColorSpaceRef colorSpace = [[color colorSpace] CGColorSpace]; [color getComponents:(CGFloat *)&components]; CGColorRef cgColor = CGColorCreate(colorSpace, components); return cgColor; }
Easy.
NSView 백그라운드 색상, 이미지 설정.
NSView 에는 배경색상을 설정하기 위한 별도의 메소드가 없습니다.
가장 심플한 뷰인데 이런 메소드가 없어서 직접 커스텀 뷰를 만들어서 NSView를 상속받고,
- (void) drawRect:(NSRect)dirtRect;
메소드를 Override 해야합니다.
참고로, 인자로 넘어오는 dirtRect 는 NSView 의 전체 프레임이 아니고,
갱신되어야하는 영역입니다. (invalidate rect 를 생각하면 될 듯..)
* 배경색상 채우기
- (void) drawRect:(NSRect)dirtRect
{
[[NSColor blueColor] setFill];
NSRectFill([self bounds]);
}
위 [NSColor blueColor] 를 변경하기 위한 멤버만 추가하면 되겠군요..
* 배경패턴이미지 채우기
- (void) drawRect:(NSRect)dirtRect
{
[[NSColor colorWithPatternImage:patternImage] setFill];
NSRectFill([self bounds]);
}