我使用下面的代码在两个UIImageViews之间转换。
-(void)performTransitionNew: (NSInteger)type subType:(NSInteger)subType
fromImageView:(UIImageView *)fromImageView
toImageView:(UIImageView *)toImageView duration:(NSInteger)duration;
{
CATransition *transition = [CATransition animation];
transition.duration = duration;//0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
NSString *subtypes[4] = { kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};
transition.type = types[type];
transition.subtype = subtypes[subType];
transitioning = YES;
transition.delegate = self;
[self.aUIView.layer addAnimation:transition forKey:nil];
fromImageView.hidden = YES;
toImageView.hidden = NO;
UIImageView *tmp = toImageView;
toImageView = fromImageView;
toImageView = tmp;
}
他们都在UIView'aUIView'上。 我希望结果是这样的:
但它显示如下:
看起来toImageView来自aUIView之外。
欢迎任何评论。
答案 0 :(得分:0)
问题是,UIView位于另一个View的顶部(滑块是)您可以更改这些视图的顺序。如果UIView在另一个之前,则子视图也是,无论它们是否在父视图的边界内。