site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=vS6z7BIj7hdGY7ju5MfqRY95PZcJJvXjmn4Hlj4e6ZQ=; b=sVvJTeRkMRb5K3+xSfN8hHGCyhLW4ayv8ItjBH1nrG2p2bB4XVSVlPHpNOd1eUjHJs 2dhdrhw+aRkIdDltyHIpmxRr3m3BtjXkRWp2hrhehQDdi6QTFfmPLOnAlIBbaDZk2APr xtE4RAGlWSZQTmNR+wA+tT2rYrYg1x/HADeZo= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=YRLh1LsJ/IlFiRx0aYFxaOxHCbD9wLJQ0nsffGPV1sn0uaKitKmZRaYDbI7PiFushx Ca87oSjb/q3sXBSppMy53nfvp7FTWUqIwTOkg78sncEoqvBx0ZZpDi8nRsN7eb//q1I2 18UL5gEPTWoFdami6KBKn2GV2TLxAQQajlGS4= On Mon, Sep 29, 2008 at 7:21 PM, Daniel Weber <dan.j.weber@gmail.com> wrote:
Hi, I have a custom view that takes up the whole frame of my textured window. Normally, the corners of a textured window are rounded. However, since my custom view is rectangular, it draws over the rounded corners. I am using Core Animation to draw in the view. I think what I need to do is clip my drawing so the corners are transparent, but I haven't been successful. What I've tried so far is drawing a rectangle with rounded corners that approximates the window's rounded corners using CGContextAddArcToPoint. Then I call CGContextClip. But it's not working, all I'm seeing is garbage at the window corners, not transparency. Any suggestions?
You need to ensure a couple of things to ensure that transparency appears there. 1) setOpaque:NO on the NSWindow you're in. By default this is YES, with what I assume are obvious consequences. 2) Return NO from -isOpaque in your NSView. NO is the default value but it can be overridden by subclasses. And then one of: 3a) Set the NSWindow's background color to [NSColor clearColor]. 3b) Clear your contents by filling with [NSColor clearColor] (using NSCompositeCopy to make sure it doesn't just get blended with what's already there) before clipping and drawing your real contents. (Note that step 2 is not strictly necessary with step 3b depending on what the rest of the drawing does, but it doesn't hurt and the reasoning involved is beyond the scope of this message.) Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... This email sent to site_archiver@lists.apple.com