Friday 9 January 2015

Jogendra Singh

UITextField move up when keyboard appears in Swift

UITextField move up when keyboard appears in Swift   :  In swift language have minor change other thing have same - 

Moving view on click of UITexField in swift language

Some textfield hide behind keyboard so how can we move view on textfield editing . So we can work on this ..

Here I have make a function for this , in this you can pass want view move then pass "true" and with your movement height

    func textFieldDidBeginEditing(textField: UITextField) {
            animateViewMoving(true, moveValue: 100)
    func textFieldDidEndEditing(textField: UITextField) {
            animateViewMoving(false, moveValue: 100)
    func animateViewMoving (up:Bool, moveValue :CGFloat){
        var movementDuration:NSTimeInterval = 0.3
        var movement:CGFloat = ( up ? -moveValue : moveValue)
        UIView.beginAnimations( "animateView", context: nil)
        UIView.setAnimationDuration(movementDuration )
        self.view.frame = CGRectOffset(self.view.frame, 0,  movement)

If you want do this same thing in objective-C then visit on this post Moving UIView up when UITextField is selected

Try this it will work fine , I have tested this ..

Thanks for Visit  , Also can visit on My blog Facebook page iPhone & iPad Application Development Help World and also can visit Google+ 

Jogendra Singh

About Jogendra Singh -

I'm Founder of Jogendra.Com. I love to share my bright ideas with the whole blogging community. I'm a good iPhone Application Developer. Apart from Blogging, I love to play Cricket and mobile games (Clash of clans).

Subscribe to this Blog via Email :


Write comments
7 May 2018 at 16:16 delete

I have passed my view outlet reference in animate view string nothing happened I have added top and bottom constraint to it.

24 October 2019 at 14:15 delete

within scrollview it will not work..Please help