Created
May 7, 2011 12:51
-
-
Save ddribin/960471 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewA.m | |
// test | |
// | |
// Created by Duncan Wilcox on 5/7/11. | |
// Copyright 2011 __MyCompanyName__. All rights reserved. | |
// | |
#import "ViewA.h" | |
@implementation ViewA | |
- (id)initWithFrame:(NSRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
// Initialization code here. | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
[super dealloc]; | |
} | |
- (void)drawRect:(NSRect)dirtyRect | |
{ | |
[NSGraphicsContext saveGraphicsState]; | |
// Set a "baseline" clip of the bounds rect. But by reversing the path, any paths that get | |
// appended will "punch a hole" in the bounds rect. | |
NSBezierPath * clipPath = [[NSBezierPath bezierPathWithRect:[self bounds]] bezierPathByReversingPath]; | |
[clipPath appendBezierPath:[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(50, 50, 50, 50)]]; | |
[clipPath appendBezierPath:[NSBezierPath bezierPathWithRect:NSMakeRect(150, 150, 50, 75)]]; | |
[clipPath addClip]; | |
[[NSColor redColor] set]; | |
[[NSBezierPath bezierPathWithRect:self.bounds] fill]; | |
[NSGraphicsContext restoreGraphicsState]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment