Kunal Gupta
Kunal Gupta

Reputation: 3074

How to animate a particular view in View controller

I have a view (View X) in a View Controller and on completion of some task I want to flip that view and show a image view on that location along with flip animation. I am using this code right now but this animates the whole view controller.

[UIView transitionFromView:_viewVerification // view to hide
                    toView:_imageviewDone // image to display
                  duration:0.5
                   options:UIViewAnimationOptionTransitionFlipFromRight
                completion:nil];

Any idea how can i implement this thing?

Thanks.

Upvotes: 0

Views: 311

Answers (2)

Mr. Bean
Mr. Bean

Reputation: 4281

front and back are two views which will be contained in card view (Parent View of front and back view which will be flipped) . Now when View controller launches one of the view (either back or front) will be hidden . You can contain imageView in one of the view and you can make _viewVerification as any of the other view

if(self.back.hidden) {
        self.front.hidden = true
        self.back.hidden = false
        UIView.transitionWithView(cardView, duration: 1.0, options: UIViewAnimationOptions.TransitionFlipFromRight, animations: {

            }, completion: nil)
        } 
else {
        self.front.hidden = false
        self.back.hidden = true
        UIView.transitionWithView(cardView, duration: 1.0, options: UIViewAnimationOptions.TransitionFlipFromLeft    , animations: {

            }, completion: nil)


    }

Upvotes: 1

raj yadav
raj yadav

Reputation: 115

Please change this according your requirements hope this will work for you.

 int x=15,c=0,y=5,z=110,image_count=1;
        for (int i=0; i<trailsInfoArray.count; i++) { if(c==3)
        {
        c=0;
        x=x+110;
        }
        [UIView animateWithDuration:1.0f
                                          delay:0.3f
                                        options:UIViewAnimationOptionCurveEaseOut
                                     animations:^(void) {
                                         tileImage.frame = CGRectMake(y+(c*z), x, 90, 90);
                                     }
                                     completion:NULL];


}

Upvotes: 1

Related Questions