Re: Interface Builder Layer Transitions
Re: Interface Builder Layer Transitions
- Subject: Re: Interface Builder Layer Transitions
- From: Troy Stephens <email@hidden>
- Date: Mon, 7 Jan 2008 17:42:26 -0800
On Jan 7, 2008, at 2:16 PM, Andrew Pouliot wrote:
I'm trying to use Core Animation to make a "push" transition for
subviews inside a window with previous and next buttons.
I tried setting the transition effects in IB for each view's "Order
In" transition, as well as setting the containing view's "Subviews"
transition, to no avail.
[subviewArea addSubview:view] causes an immediate transition, while
[[subviewArea animator] addSubview:view] causes a fade transition, not
the transition I was expecting
When I ask [[view layer] animationForKey:NSViewAnimationFadeInEffect]
in gdb it returns nil. Not sure if this is related.
Here is the test project I'm working on:
http://beta.darknoon.com/andpoul/IBTransitionTest.zip
I searched in the archive and didn't turn up anything. Any help would
be greatly appreciated!
—Andrew Pouliot / darknoon
Hi Andrew,
It's the contents of the "subviewArea" view's "animations" dictionary
that matters, and there is a known problem with the IB inspector that
prevents the requested transition type from being set properly in
the .nib. This is being worked on. Meanwhile, if you set up the
transition in code instead, you can make this work as desired. Try
changing your Controller class implementation to the following.
You'll get a push transition that moves forward when the user clicks
"Next", and back for "Prev".
@implementation Controller
- (void)makeCurrent:(NSView *)view direction:(NSString
*)transitionDirection {
if (current) {
CATransition *transition = [CATransition animation];
[transition setType:kCATransitionPush];
[transition setSubtype:transitionDirection];
[subviewArea setAnimations:[NSDictionary
dictionaryWithObject:transition forKey:@"subviews"]];
[[subviewArea animator] replaceSubview:current with:view];
} else {
[subviewArea addSubview:view];
}
current = view;
}
- (void)awakeFromNib {
[self makeCurrent:view1 direction:kCATransitionFromLeft];
}
- (IBAction)next:(id)sender {
NSView *view = (current == view2) ? view1 : view2;
[self makeCurrent:view direction:kCATransitionFromRight];
}
- (IBAction)prev:(id)sender {
NSView *view = (current == view2) ? view1 : view2;
[self makeCurrent:view direction:kCATransitionFromLeft];
}
@end
--
Troy Stephens
Cocoa Frameworks
Apple, Inc.
_______________________________________________
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