• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Displaying a string with Core Animation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Displaying a string with Core Animation


  • Subject: Displaying a string with Core Animation
  • From: Gabriel Zachmann <email@hidden>
  • Date: Wed, 30 Sep 2009 12:41:24 +0200

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 (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

  • Follow-Ups:
    • Re: Displaying a string with Core Animation
      • From: douglas welton <email@hidden>
    • Re: Displaying a string with Core Animation
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Nib Loading Crash on Tiger only -- SOLVED (well made gone...)
  • Next by Date: Re: Does Core Data have reserved Entity names?
  • Previous by thread: Re: Does Core Data have reserved Entity names?
  • Next by thread: Re: Displaying a string with Core Animation
  • Index(es):
    • Date
    • Thread