Using transition CIFilters for CATransition
Asked Answered
S

2

7

I'm trying to use CATransition's filter property with the new iOS 6 transition animations (CIBarsSwipeTransition, CICopyMachineTransition, etc.). The CIFilter documentation says that these are available on iOS 6, and nothing on the CATransition documentation says that the filter property cannot be used.

But, I can't seem to get them to work. I don't know if Apple just failed to mention the inavailability of the functionality or I'm just missing something to make it work. Here's how I set it up:

CIFilter *transitionFilter = [CIFilter filterWithName:@"CIBarsSwipeTransition"];
[transitionFilter setDefaults];

CATransition *transition = [CATransition new];
transition.duration = 0.4f;
transition.filter = transitionFilter;

[self.view.layer addAnimation:transition forKey:kCATransition];

Any pointers are appreciated.

Sweetener answered 11/11, 2012 at 6:46 Comment(0)
A
3

I'm not sure it is possible on iOS. From the CATransition documentation:

If specified, the filter must support both kCIInputImageKey and kCIInputTargetImageKey input keys, and the kCIOutputImageKey output key.

From the CIFilter documentation (constants section) (emphasis mine)

kCIInputTargetImageKey

A key for a CIImage object that is the target image for a transition. Available in OS X v10.5 and later. Not available in iOS.

The filter exists, and inputTargetImage is one of the input keys, but even if you create the core image data yourself and assign it to the properties (which displays properly in the debugger) then you still don't get the effect.

Creating the same effect on OS X is as simple as the code in your question. I have filed this as a radar (13281399).

Arst answered 24/2, 2013 at 15:2 Comment(2)
Can you provide a link to the documentation that mentions the "Not available in iOS?" The documentations I linked in my question doesn't mention that. Anyway, I gave up on this a long time ago and made my own custom implementation. I'll mark this as the answer since you seem to have looked up about this more than I did as to have filed a radar.Sweetener
Link added to answer. The constants section is at the bottom.Arst
D
4

I know that question is quite old but I got mine working by following that link

https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_tasks/ci_tasks.html

Check the 11 steps in the section "Using Transition Effects" it works on iOS as well

Dodgson answered 16/11, 2012 at 17:16 Comment(1)
I know that documentation and I know those are the steps to create individual frames. Does that mean I have to subclass CATransition and implement the transition myself? That seems pretty useless for the filter property to exist at all.Sweetener
A
3

I'm not sure it is possible on iOS. From the CATransition documentation:

If specified, the filter must support both kCIInputImageKey and kCIInputTargetImageKey input keys, and the kCIOutputImageKey output key.

From the CIFilter documentation (constants section) (emphasis mine)

kCIInputTargetImageKey

A key for a CIImage object that is the target image for a transition. Available in OS X v10.5 and later. Not available in iOS.

The filter exists, and inputTargetImage is one of the input keys, but even if you create the core image data yourself and assign it to the properties (which displays properly in the debugger) then you still don't get the effect.

Creating the same effect on OS X is as simple as the code in your question. I have filed this as a radar (13281399).

Arst answered 24/2, 2013 at 15:2 Comment(2)
Can you provide a link to the documentation that mentions the "Not available in iOS?" The documentations I linked in my question doesn't mention that. Anyway, I gave up on this a long time ago and made my own custom implementation. I'll mark this as the answer since you seem to have looked up about this more than I did as to have filed a radar.Sweetener
Link added to answer. The constants section is at the bottom.Arst

© 2022 - 2024 — McMap. All rights reserved.