Re: Displaying a string with Core Animation

2009-09-30 Thread douglas welton
I've been tripped up by this more than once:  Did you add your new  
CATextLayer to your layer hierarchy?


On Sep 30, 2009, at 6:41 AM, Gabriel Zachmann wrote:

I also tried to make my view layer hosted and add a CATextLayer with  
the string property set to my message string (and font and fontSize).

But that never gets displayed.



___

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying a string with Core Animation

2009-09-30 Thread Jens Alfke


On Sep 30, 2009, at 3:41 AM, Gabriel Zachmann wrote:


This sort of works, EXCEPT that the string is always behind the image!
I tried to set the zPosition of my image sub-layer to either +1.0 or  
-1.0, to no avail.


I think layers are always drawn in front of the view's own content.

I also tried to make my view layer hosted and add a CATextLayer with  
the string property set to my message string (and font and fontSize).

But that never gets displayed.


That's the way I would do it. Something must be wrong with the way you  
set up the text layer; maybe its coordinates put it outside the view's  
bounds.


—Jens___

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Displaying a string with Core Animation

2009-09-30 Thread Gabriel Zachmann
I am at a loss at how to display a single string at the bottom left in  
a view with core animation.
The view is actually a ScreensaverView, and the string is a status  
message that should be always in front of the other layer(s).
The other layer contains just an image; the layer gets removed at some  
point, at which I add another layer to the main layer (this  
transaction is animated).


Right now I tried this:

// make the view layer-backed and become the delegate for the layer
self.wantsLayer = YES;
mainLayer_ = self.layer;
mainLayer_.name = @"mainLayer";
mainLayer_.zPosition = 0.0;
mainLayer_.delegate = self;
[mainLayer_ setNeedsDisplay];

Then, I create one layer containing the image and add it to the  
mainLayer.


Eventually, the method drawRect: of my screensaverview gets called,  
where I render the string like so:


[[NSColor blackColor] set];
NSRectFill(rects);

NSMutableAttributedString * str = [[NSMutableAttributedString  
alloc] initWithString: mesg];

...
NSShadow * shadow1 = [[NSShadow alloc] init];
...
[str addAttribute: NSShadowAttributeName value: shadow1 range:  
NSMakeRange(0, [str length])];

[str drawAtPoint: NSMakePoint(0,0)];

This sort of works, EXCEPT that the string is always behind the image!
I tried to set the zPosition of my image sub-layer to either +1.0 or  
-1.0, to no avail.


I also tried to make my view layer hosted and add a CATextLayer with  
the string property set to my message string (and font and fontSize).

But that never gets displayed.

Any help will be highly appreciated.

Best regards,
Gabriel.




smime.p7s
Description: S/MIME cryptographic signature
___

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com