• 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
Re: Carousel - like control for Mac OS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Carousel - like control for Mac OS


  • Subject: Re: Carousel - like control for Mac OS
  • From: vincent habchi <email@hidden>
  • Date: Wed, 21 Dec 2011 11:55:03 +0100

Nick,

I cannot elaborate much on this and give you code (not because it is somehow confidential, but just because it is a general idea I don’t have implemented, though I’m familiar with CAScrollLayers). The idea is thus:

1. Draw a normal NSView that you back with a CAScrollLayer. Give it the right size.
2. Generate a NSArray of CALayers, each one initialized with a single image.
3. Put as sublayers of your CAScrollLayer as many CALayers as you want images displayed, giving each CALayer origin the right position (ex: (0,0) - (0, 100) - (0, 200) if you display three images of 100x100 pixels each). Your CAScrollLayer should have its origin at (0, 0).
4. Use standard event handling methods to detect mouse click.
5. If you want to scroll, say leftwards, add a new sublayer with the proper image at (0, 300), then animate the origin of the CAScrollLayer from (0,0) to (0, 100). Once the animation is done, you can safely remove the (0, 0) sublayer.
6. Go back to 4.

The NSArray is a sort of cache where the CALayer live. This is more efficient than generating a CALayer on the fly each time you scroll.

Vincent_______________________________________________

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

References: 
 >Carousel - like control for Mac OS (From: Nick <email@hidden>)
 >Re: Carousel - like control for Mac OS (From: "Stephen J. Butler" <email@hidden>)
 >Re: Carousel - like control for Mac OS (From: Nick <email@hidden>)
 >Re: Carousel - like control for Mac OS (From: Vincent Habchi <email@hidden>)
 >Re: Carousel - like control for Mac OS (From: Nick <email@hidden>)

  • Prev by Date: Re: Lion: Batch close
  • Next by Date: Cocoa-dev Digest, Vol 8, Issue 979
  • Previous by thread: Re: Carousel - like control for Mac OS
  • Next by thread: Account validation in CocoaTouch for the purchased app
  • Index(es):
    • Date
    • Thread