Re: Semi-transparent offscreen CALayer
Re: Semi-transparent offscreen CALayer
- Subject: Re: Semi-transparent offscreen CALayer
- From: Shaun Larkin <email@hidden>
- Date: Thu, 28 Aug 2008 08:19:13 -0700 (PDT)
Solution found, I wasn't setting the bounds properly.
----- Original Message ----
From: Shaun Larkin <email@hidden>
To: cocoa-dev <email@hidden>
Sent: Thursday, August 28, 2008 10:16:03 AM
Subject: Semi-transparent offscreen CALayer
I'm trying to animate a semi-transparent CALayer (opacity 0.8) by sliding it in from offscreen but it only seems to exist is it's opaque:YES is set, essentially negating any transparent effects. I've look through the documentation but haven't found a solution. I had assumed that when the calayer appears in context it would would be rendered.
here is the code ::
// the transparent calayer is a subclass called Menu.m
-(void)drawInContext:(CGContextRef)ctx {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGFloat col[4] = {0,0,0,0.5};
CGColorRef colr = CGColorCreate(space, col);
CGColorSpaceRelease(space);
CGContextSetFillColorWithColor(ctx, colr);
CGColorRelease(colr);
CGContextFillRect(ctx, [self frame]);
}
//in the layer hosting view , this on work if the menu's opaque property is set to YES
CABasicAnimation * b = [CABasicAnimation animationWithKeyPath:@"position.y"];
b.duration = 0.4f;
b.fromValue = [NSNumber numberWithFloat:menu.frame.origin.y];
b.toValue = [NSNumber numberWithFloat:360.0];
b.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
b.removedOnCompletion = NO;
b.fillMode = kCAFillModeForwards;
[menu addAnimation:b forKey:@"slideIn"];
thanks in advance!
_________________________________
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
__________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now at
http://ca.toolbar.yahoo.com.
_______________________________________________
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
__________________________________________________________________
Connect with friends from any web browser - no download required. Try the new Yahoo! Canada Messenger for the Web BETA at http://ca.messenger.yahoo.com/webmessengerpromo.php
_______________________________________________
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