2011-03-07 99 views
1

有人有想法按面板显示图像。目前我有一个漫画图像,在那个图像中有4个面板,我需要将这个图像分割成4个面板&想要在iPhone中显示四个面板的顺序,任何机构都有关于它的想法?带面板视图的漫画书

在此先感谢。

回答

0

你应该看看Cocos2D库。它也有一个非常漂亮的翻页动画。

就你而言,我不想修改图像,只是视图显示的部分。您可以通过更改UIScrollView的内容矩形在UIKit中执行此操作。

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

+0

我想二硝基甲苯任何动画。但我想在四个面板中分割图像。而在漫画面板的每个图像尺寸都不相同。那么如何管理呢? – iCoderz 2011-03-07 17:11:11

+0

您必须查看图像并为每个漫画页面编写一个配置“.plist”。 iPhone上可能没有一种快速计算的方法。 [检查这个问题](http://www.cocos2d-iphone.org/forum/topic/1697),你需要更多地了解Cocos2D,然后才能有更多的帮助。 – 2011-03-07 18:08:13

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