• 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
Resizing CAScrollLayer while maintaining current focus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resizing CAScrollLayer while maintaining current focus?


  • Subject: Resizing CAScrollLayer while maintaining current focus?
  • From: Colin Cornaby <email@hidden>
  • Date: Mon, 3 Dec 2007 16:18:04 -0800

I have a CAScrollLayer that I am doing a scaling transform on, and I'd like to maintain it's current focus, i.e., I'd like to be the center of it's focus to be maintained so whatever point that was in the center of the current focus stays the center of the current focus as the scroll layer scales.

I'm using the following code:

//Get the current anchor point and store it for restoring later
CGPoint anchorPoint = scrollLayer.anchorPoint;
//Adjust the anchor point
scrollLayer.anchorPoint = CGPointMake(0.5,0.5);
//Scale the layer
scrollLayer.transform = CATransform3DMakeScale(newScale, newScale, 1.0);
//Adjust the bounds so that it fills the parent layer
scrollLayer.bounds = CGRectMake (scrollLayer .bounds.origin.x,scrollLayer.bounds.origin.y,self.bounds.size.width/ newScale,self.bounds.size.height/newScale);
//restore the anchor point
scrollLayer.anchorPoint = anchorPoint;


The code doesn't seem to work though, and scales as if the anchor point was set to the lower left (which is what I have it originally set to before this code runs). Has anyone else ran into this issue? I have some code to manually maintain the focus written for an OpenGL version of this program, but I'd rather use something cleaner and built into CoreAnimation.

Thanks,
Colin
_______________________________________________

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


  • Prev by Date: Re: Determine whether a file has a custom icon
  • Next by Date: problem with buttons in toolbar
  • Previous by thread: Re: NSString and control-@ character
  • Next by thread: problem with buttons in toolbar
  • Index(es):
    • Date
    • Thread