• 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
autolayout-based animation on NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

autolayout-based animation on NSView


  • Subject: autolayout-based animation on NSView
  • From: Roland King <email@hidden>
  • Date: Thu, 14 Aug 2014 09:22:58 +0800

I have a constraint-based NSView layout which I can flip between states by adjusting the constraint priorities and/or constants, and/or removing and replacing some constraints. At the same time I make some views invisible or visible again. All that stuff say is in a method on the view ..

	-(void)updateConstraintsAndVariousViewPropertiesForState:(BOOL)state;

With the fairly straightforward UIView on iOS I’m used to doing this

	[ myUIView layoutIfNeeded ]
	[ myUIView animateWithDuration:duration animations:^{
		[ myUIView updateConstraintsAndVariousViewPropertiesForState:state ];
		[ myUIView layoutIfNeeded ];
	} ];

The view properties change, the second layoutIfNeeded re-evaluates the constraints and fixed up all the frames and bounds etc and the whole thing animates smoothly to the new state.

How do I do this with an *NSView*?

Doing some docs diving I found animator proxies, get the proxy, call the method on the proxy and it should animate. So I tried

	[ myNSView layoutSubtreeIfNeeded ];
	[ myNSView updateConstraintsAndVariousViewPropertiesForState:state ];
	[ [ myNSView animator ] layoutSubtreeIfNeeded ];

no animation, layout change, but no animation, just jumps. I put it in an NSAnimationContext beginGrouping/endGrouping box … that didn’t help. Changing some alpha properties in the same block did animate, but it seems the layoutSubtreeIfNeeded doesn’t work with animator proxies. I tried just setting constraint priorities using their animator proxies, that didn’t work either, still just jumped. Looks like the only animator proxy able thing on a constraint is the constant. So it looks like animator proxies aren’t going to fly.

Where do I go next? I see a few comments about layer-backed views, but examples are few, do I need to back myself with a layer for this?



_______________________________________________

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: autolayout-based animation on NSView
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: KVO query
  • Next by Date: Re: autolayout-based animation on NSView
  • Previous by thread: Re: KVO query
  • Next by thread: Re: autolayout-based animation on NSView
  • Index(es):
    • Date
    • Thread