繁体   English   中英

UIView transitionWithView:不起作用

[英]UIView transitionWithView: not working

我正在为漫画书应用程序设计布局。 漫画书的页面分为几行,然后每一行至少有一列。 当用户在列上进行垂直滑动时,应该将其分为两个单独的列。 该部分已经可以正常工作,但是我想使用+ transitionWithView:为此添加一个简单的向上卷曲过渡。 一切仍然正常(该列划分很好),但是没有动画。 这是代码:

- (void)divideColumnView:(CCLayoutColumnView *)columnView atPoint:(CGPoint)_divisionPoint {
// divides a single column into two smaller ones

// define frames for new columns
CGRect frameLeft = columnView.frame;
CGRect frameRight = frameLeft;
CGFloat width = _divisionPoint.x - frameLeft.origin.x;
frameLeft.size.width = width;
frameRight.size.width -= width;
frameRight.origin.x += width;


// set up the container for transition
UIView *rowView = [columnView superview];
UIView *containerView = [[UIView alloc] initWithFrame:columnView.frame];
[rowView addSubview:containerView];

// move the column to the container
columnView.frame = [containerView convertRect:columnView.frame fromView:rowView];
[containerView addSubview:columnView];

// set up columns that will be inserted to the container during transition
CCLayoutColumnView *leftColumnView = [[CCLayoutColumnView alloc] initWithFrame:[containerView convertRect:frameLeft fromView:rowView]];
CCLayoutColumnView *rightColumnView = [[CCLayoutColumnView alloc] initWithFrame:[containerView convertRect:frameRight fromView:rowView]];

[UIView transitionWithView:containerView
                  duration:0.5
                   options:UIViewAnimationOptionTransitionCurlUp
                animations:^{
                    [columnView removeFromSuperview];
                    [containerView addSubview:leftColumnView];
                    [containerView addSubview:rightColumnView];
                }
                completion:^(BOOL finished){
                    // add columns to their row
                    leftColumnView.frame = frameLeft;
                    rightColumnView.frame = frameRight;
                    [rowView addSubview:leftColumnView];
                    [rowView addSubview:rightColumnView];

                    // clean up
                    [containerView removeFromSuperview];
                    [containerView release];
                    [leftColumnView release];
                    [rightColumnView release];
                }];

}

我已经检查了所有视图的几何形状,看起来还可以。 另外,完成块可以正确执行。

可能是什么问题?

我还被困在使用transitionWithView为视图设置动画的transitionWithView

我不知道您的项目的层次结构,但是如果您可以为要为其创建动画的视图创建一个单独的类,那将很容易:

[UIView transitionWithView:self.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{} completion:^(BOOL f){}];

works..ie此功能与正常工作self.view

希望对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM