触摸滚动动画以获取iOS中的图像列表

时间:2013-03-02 09:52:31

标签: animation ios6 uiscrollview uiimageview uianimation

enter image description here我的要求是以水平的方式显示图像列表。当我触摸图像时,它会移到一边,下一个图像会出现在前面。这样我需要将图像移到一边。那么有什么方法可以滚动图像列表吗?或者我可以选择任何类型的动画吗?

通过这种方式放置和移动图像。请告诉我如何进行?

2 个答案:

答案 0 :(得分:0)

我解决了这个问题。我在这个链接中找到了示例。http://code4app.net/category/scrollview

答案 1 :(得分:0)

我创建了一个封面流程的工作模块.....

尝试在层上进行转换,允许使用....进行3D转换。

-(void) rotateView3D:(UIView *)myView:(CGFloat)angle
{

    CATransform3D affinAndScaleTransform;
    if (angle==30.0f||angle==-30.0f)
    {
        affinAndScaleTransform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0.9f, 0.9f));
    }
    else
    {
        affinAndScaleTransform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(1.0f, 1.0f));
    }
    CALayer *layer = myView.layer;

//    layer.borderColor = [[UIColor blackColor] CGColor];
//    layer.borderWidth = 2.0f;
    CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;

    rotationAndPerspectiveTransform.m34 = 1.0 / -500;
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, angle * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
    [layer setTransform:CATransform3DConcat(rotationAndPerspectiveTransform, affinAndScaleTransform)];
}

滚动视图添加手势.......

左手势使用这样的thig ........

{
    UIView * view0 = [self.view viewWithTag:-1111];
    UIView * view1 = [self.view viewWithTag:1111];
    UIView * view2 = [self.view viewWithTag:2222];
    UIView * view3 = [self.view viewWithTag:3333];
    UIView * view4 = [self.view viewWithTag:4444];

    [view4 setFrame:self.rect0];

    int preViewNo = self.leftProduct-1;
    if (preViewNo<0)preViewNo=self.productArray.count-1;

    [UIView animateWithDuration:0.4 animations:^
     {
         [view0 setFrame:self.rect1];
         [self rotateView3D:view0 : 30.0f];

         [view1 setFrame:self.rect2];
         [self rotateView3D:view1 : 0.0f];

         [view2 setFrame:self.rect3];
         [self rotateView3D:view2 : -30.0f];

         [view3 setFrame:self.rect4];
         [self rotateView3D:view4 : 0.0f];

     }];

    [self setdescriptionView:view0 :[self.productArray objectAtIndex:preViewNo]];

    [view0 setTag:1111];
    [view1 setTag:2222];
    [view2 setTag:3333];
    [view3 setTag:4444];
    [view4 setTag:-1111];

    self.currentProduct--;
    self.rightProduct--;
    self.leftProduct--;
    if (self.currentProduct < 0) self.currentProduct=self.productArray.count-1;
    if (self.rightProduct < 0) self.rightProduct=self.productArray.count-1;
    if (self.leftProduct < 0) self.leftProduct=self.productArray.count-1;


}
右手势识别器上的

使用这样的东西.......

{
    UIView * view0 = [self.view viewWithTag:-1111];
    UIView * view1 = [self.view viewWithTag:1111];
    UIView * view2 = [self.view viewWithTag:2222];
    UIView * view3 = [self.view viewWithTag:3333];
    UIView * view4 = [self.view viewWithTag:4444];

    [view0 setFrame:self.rect4];

    int nextViewNo = self.rightProduct+1;
    if (nextViewNo>=self.productArray.count)nextViewNo=0;

    [UIView animateWithDuration:0.4 animations:^
     {
         [view4 setFrame:self.rect3];
         [self rotateView3D:view4 : -30.0f];

         [view3 setFrame:self.rect2];
         [self rotateView3D:view3 : 0.0f];

         [view2 setFrame:self.rect1];
         [self rotateView3D:view2 : 30.0f];

         [view1 setFrame:self.rect0];
         [self rotateView3D:view1 : 0.0f];

     }];

    [self setdescriptionView:view4 :[self.productArray objectAtIndex:nextViewNo]];

    [view0 setTag:4444];
    [view1 setTag:-1111];
    [view2 setTag:1111];
    [view3 setTag:2222];
    [view4 setTag:3333];

    self.currentProduct++;
    self.rightProduct++;
    self.leftProduct++;
    if (self.currentProduct >= self.productArray.count) self.currentProduct=0;
    if (self.rightProduct >= self.productArray.count) self.rightProduct=0;
    if (self.leftProduct >= self.productArray.count) self.leftProduct=0;
}

由于某些技术原因,我必须自定义封面....

你也可以尝试这个......

icarousal