Drawing issues in custom view
Drawing issues in custom view
- Subject: Drawing issues in custom view
- From: Jason Wiggins <email@hidden>
- Date: Fri, 11 Jul 2008 01:38:35 +1000
Hi everyone,
I have a Custom View in IB with an rounded NSTokenField (Focus ring
set to none) and a rounded rect NSButton embedded in it. In XCode I
have the Custom View class set to my subclass of NSView, with the
following code:
- (void)drawRect:(NSRect)rect {
NSGradient *gradient = nil;
NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect];
[[NSColor blackColor] setFill];
[path fill];
// Create gloss gradient
gradient = [[NSGradient alloc] initWithStartingColor:[NSColor
colorWithCalibratedWhite:1.0 alpha:0.3]
endingColor:[NSColorcolorWithCalibratedWhite:1.0alpha:
0.2]];
// Make a half-height rectangle
rect = NSMakeRect(rect.origin.x, (rect.origin.y + (rect.size.height)/
2), rect.size.width, (rect.size.height)/2);
path = [NSBezierPath bezierPathWithRect:rect];
[gradient drawInBezierPath:path angle:-90];
// Create upper highlight
path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(rect.origin.x, (rect.origin.y +
rect.size.height))];
[path lineToPoint:NSMakePoint(rect.size.width, (rect.origin.y +
rect.size.height))];
[path closePath];
[path setLineWidth:2];
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] setStroke];
[path stroke];
}
The gradient draws as expected. The upper highlight also draws as
expected in the view, but also on the NSTokenView and NSButton, which
is unexpected and I don't know why this is so. Can anyone offer any
info as to why this is the case?
Regards,
JJ
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden