• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Drawing issues in custom view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Drawing issues in custom view
      • From: Jason Wiggins <email@hidden>
  • Prev by Date: Re: Receive notifications about frontmost application change
  • Next by Date: Re: Why can't I name a property `tag'?
  • Previous by thread: Re: String Encoding problem with Unicode
  • Next by thread: Re: Drawing issues in custom view
  • Index(es):
    • Date
    • Thread