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.


Attachment: 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

Reply via email to