How to move the uiview from left to right and vice versa

前端 未结 5 1095
自闭症患者
自闭症患者 2021-01-01 05:43

Hi I am developing one application.In that i did the animation for one view to move from left to right and right to left and changing the values for labels contained in that

5条回答
  •  独厮守ぢ
    2021-01-01 06:00

    when Button click UIView slide right to left and left to right.

    Global Declare NSString *string = @"one";

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        stringslider = @"one";
    }
    
    Action Button "click"
    
    -(IBAction)slider:(id)sender{
        if ([stringslider isEqualToString:@"one"]) {
            [UIView animateWithDuration:0.2
                         animations:^{[sliderview setFrame:CGRectMake(205, [sliderview frame].origin.y, 116, 275)];
                         }
    
                         completion:nil];
            stringslider = @"two";
        }
     else if ([stringslider isEqualToString:@"two"]) {
            [UIView animateWithDuration:0.2
                             animations:^{[sliderview setFrame:CGRectMake(342, [sliderview frame].origin.y, 116, 275)];
                             }
             completion:nil];
            stringslider = @"one";
    
    }
    }
    
    
    easy uiview animation is done.
    

提交回复
热议问题