Comic book with panel by panel view
Is anybody have idea to show image panel by panel . Currently i have one comic image ,in that image there are 4 panels , I need to split that image in 4 panels & want to show that four p开发者_StackOverflowanels in sequence in iPhone , Any body have a idea about it ?
Thanks in advance .
You should look at the Cocos2D Library. It also has a very nice page-turn animation.
In your case, I wouldn't want to modify the image, just the portion that the view is displaying. You could do this in UIKit by changing the content rect of a UIScrollView.
Or, with Cocos2D you could treat each panel as a Sprite in a SpriteSheet, and display them sequentially.
Try this working solution. You need to have the frames/panels response with you and use the below method
- (BOOL)zoomPanel
{
//Grab the frame from the database
CKUViewFrame* frame = [self.uview frameForPage:self.pageIndex
frame:self.frameIndex];
if (frame == nil)
{
return NO;
}
//Translate the timing
NSTimeInterval animationTime = [frame.animationDuration
doubleValue];
UIViewAnimationOptions animationOptions =
UIViewAnimationOptionBeginFromCurrentState | ([frame.animationCurve
integerValue] << 16);o
//Get the rects and convert to device coordinates
CGRect frameRectPercent = CGRectMake([frame.rectLeft floatValue],
[frame.rectTop floatValue], [frame.rectWidth floatValue],
[frame.rectHeight floatValue]);
CGRect frameRect = CGRectMake((frameRectPercent.origin.x *
self.pageImageView.image.size.width),
(frameRectPercent.origin.y *
self.pageImageView.image.size.height),
frameRectPercent.size.width *
self.pageImageView.image.size.width,
frameRectPercent.size.height *
self.pageImageView.image.size.height);
//Set the mask color
UIColor* maskColor = [UIColor colorWithRed:[frame.colorRedValue
floatValue] green:[frame.colorGreenValue floatValue] blue:
[frame.colorBlueValue floatValue] alpha:[frame.colorAlphaValue
floatValue]];
[UIView animateWithDuration:animationTime delay:0
options:animationOptions animations:^
{
//Determine the zoomScale to use
CGFloat zoomScale = self.view.bounds.size.width /
frameRect.size.width;
CGFloat verticalZoomScale = self.view.bounds.size.height /
frameRect.size.height;
if (verticalZoomScale < zoomScale)
{
zoomScale = verticalZoomScale;
}
//Determine the offset to use
CGFloat heightOffset = (((frameRect.size.height * zoomScale)
- (self.pageScrollView.bounds.size.height)) / 2);
CGFloat widthOffset = (((frameRect.size.width * zoomScale) -
(self.pageScrollView.bounds.size.width)) / 2);
self.pageScrollView.zoomScale = zoomScale;
self.pageScrollView.contentOffset = CGPointMake(widthOffset +
(frameRect.origin.x * zoomScale), heightOffset + (frameRect.origin.y *
zoomScale));
//Do the masking
return YES;
}
精彩评论