小编ven*_*kat的帖子

如何将uiview从左向右移动,反之亦然

嗨我正在开发一个应用程序.在那个我做了一个视图的动画从左到右和从右到左移动并更改该视图中包含的标签的值.但是当我点击向左或向右按​​钮时该视图被删除新视图覆盖旧视图.所以我不想覆盖.我想添加新视图.我的代码是

    -(void)centerAnimation1:(id)sender
     {
         UIView *currentView = daysview;
            theWindow = daysview;
         // set up an animation for the transition between the views
        CATransition *animation = [CATransition animation];
            animation.delegate = self;
        [animation setDuration:0.4];
        [animation setType:kCATransitionMoveIn];

         if(rhtolft)
         {
             [animation setSubtype:kCATransitionFromLeft];
         }
         else
         {
             [animation setSubtype:kCATransitionFromRight];
         }
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
        [[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
            [currentView removeFromSuperview];
        }


        - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{

             if(animate)
             {
                 CATransition *animation = [CATransition animation];
                 animation.delegate = self;
                 [animation setDuration:0.4];
                 [animation setType:kCATransitionMoveIn];
                 if(rhtolft)
                 {
                     [animation setSubtype:kCATransitionFromLeft];
                     rhtolft=NO;
                 }
                 else
                 {
                     [animation …
Run Code Online (Sandbox Code Playgroud)

iphone ios

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

ios ×1

iphone ×1