XBPageCurl
XBPageCurl copied to clipboard
Other side of curled page
Is it possible to have a custom image instead of the "mirrored grayed out image" on the other side of the curled top view (back of the top page), basically i want to curl a playing card lying face down and see what card i have. Thanks a bunch
I would assume this is possible... There are [XBCurlView drawViewOnBackOfPage:(UIView)view] and [XBCurlView drawImageOnBackOfPage:(UIImage)image] functions you should look at. If you're using XBPageDragView, then you'd invoke them in [XBPageDragView touchesBegan:] after it's call to [XBCurlView drawViewOnFrontOfPage:(UIView*)view].
Disclaimer: I'm guessing here, mostly. I haven't tried it.
I'm interested in this, as well. Will try your suggestion, Matt-Curtis. Kind of a noob at graphics, so all I can do is copy & paste code... Thanks.
You should do what matt-curtis said. Use the drawViewOnBackOfPage:
or the drawImageOnBackOfPage:
methods.
Yep, I used those. Thanks to both of you.
Still not sure what should be done with drawViewOnBackOfPage: and what with drawImageOnBackOfPage:, but got something working. Also had to reset color scheme on back, to remove fade effect. Here's my code, in . Sorry should have posted this earlier...
(void)refreshPageCurlView { // Existing code XBPageCurlView *pageCurlView = [[XBPageCurlView alloc] initWithFrame:self.viewToCurl.frame]; pageCurlView.pageOpaque = YES; pageCurlView.opaque = NO; pageCurlView.snappingEnabled = YES; [pageCurlView drawViewOnFrontOfPage:self.viewToCurl];
// My hack...
NSString *frontPath = [[NSBundle mainBundle] pathForResource:@"back-horizonatal-900" ofType:@"png"];
UIImage *frontCardImage = [[UIImage alloc] initWithContentsOfFile:frontPath];
[pageCurlView drawImageOnFrontOfPage:frontCardImage]; // Change the front image view
NSString *path = [[NSBundle mainBundle] pathForResource:@"QueenDiamonds" ofType:@"png"];
UIImage *backCardImage = [[UIImage alloc] initWithContentsOfFile:path];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:backCardImage];
[pageCurlView drawViewOnBackOfPage:myImageView]; // Added back view
...
And fixing the fade in Resources/BackFragmentShader.glsl
// gl_FragColor = vec4(color.rgb*(1.0 - gradient.a) + gradient.rgb, color.a); // premultiplied alpha [fading, through paper]
gl_FragColor = vec4(color.rgb, 1.0); // premultiplied alpha [no fading, full transparency!]
I should clearly define the drawImageOnFrontOfPage: at some earlier point. Still working on that. Also working on re-sizing the peel-back view to my needed exact dimensions. But that's a separate issue, and your multi-view peel example should be good enough for that purpose...
Still a Noob to Open-GL and to UIView, but your code is very well organized and so possible to understand :+1:
Looks like this. Obviously needs work, but I like the effect. further peel not as good, but can probably run trial & error with cone properties...