0

In my app i want to show a view coming from bottom. So for that i have animated the bottom constraints. The animation works fines but the issue is that the margin is not proper

original view

enter image description here

enter image description here

The issues is that the buttons are not in center

Code

let translate = CGAffineTransformMakeTranslation(0, -(view.frame.height/2 - view.center.y/4 + 20))
        let scale =  CGAffineTransformMakeScale(0.7, 0.7);
        let transform = CGAffineTransformConcat(translate, scale)


        UIView.animateWithDuration(0.6, delay: 0, options: .CurveEaseInOut, animations: {
            self.ivLogo.transform = transform
            }, completion:nil)



        self.view.layoutIfNeeded()
        //self.loginSignUpView.layoutIfNeeded()
        UIView.animateWithDuration(1.0, delay: 0, options: .CurveEaseInOut, animations: {

            self.loginSignUpBottomConst.constant=30
            self.loginSignUpView.layoutIfNeeded()
            self.view.layoutMarginsDidChange()
            }, completion: nil)


    }
Sonali Pawar
  • 420
  • 3
  • 18
  • Could you show what the view looks like before the animation? And why do you change the transform? Your question only said you want to move views upwards. – Fujia Jul 15 '16 at 06:37
  • yes the the bottom 3 buttons will come from bottom – Sonali Pawar Jul 15 '16 at 06:38
  • AutoLayout shouldn't be mixed with other layout tenichques (like directly setting frame, origin and transform), otherwise the layout behavior would be unexpected. If you just want to move views, animating the bottom constraint would suffice. Remove the first animation and see if any unpected behavior occurs. – Fujia Jul 15 '16 at 06:46
  • yes i did tat also but same thing, or else can you suggest me other way how i can animate view from bottom – Sonali Pawar Jul 15 '16 at 06:52
  • Animate just a single constraint will do it. I don't understand why you change the transform. And can you post an image of what the views looks like before the animation? – Fujia Jul 15 '16 at 06:58
  • i have edited my post – Sonali Pawar Jul 15 '16 at 07:08
  • Still not understand your intent with the images. Where does the logo go and why the width of the screen changes during the animation? – Fujia Jul 15 '16 at 07:24
  • you can simply do it by `self.view.layoutIfNeeded() UIView.animateWithDuration(1.0, animations: { self.loginSignUpBottomConst.constant=30 self.view.layoutIfNeeded() })` .. no need of other code something like http://stackoverflow.com/a/32516167/4601170 – Bhavin Bhadani Jul 15 '16 at 08:11
  • i used this but still its moving out of center – Sonali Pawar Jul 15 '16 at 09:30

0 Answers0