与面板视图的面板的漫画书

时间:2011-03-07 15:29:33

标签: image iphone

是否有人有想法按面板显示图像面板。目前我有一个漫画图像,在该图像中有4个面板,我需要将该图像分成4个面板和图像。想要在iPhone中按顺序显示四个面板,任何机构对此有所了解吗?

提前致谢。

2 个答案:

答案 0 :(得分:0)

您应该查看Cocos2D库。它还有一个非常好的翻页动画。

在您的情况下,我不想修改图像,只修改视图显示的部分。您可以通过更改UIScrollView的内容rect来在UIKit中执行此操作。

或者,使用Cocos2D,您可以将每个面板视为SpriteSheet中的Sprite,并按顺序显示它们。

答案 1 :(得分:0)

试试这个有效的解决方案。 你需要让框架/面板响应并使用以下方法

    - (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;
}