Animate the height of inputAccessoryView Swift

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 17:26:19

In your animation block you are changing the y posistion of the frame in CGRectMake rather than the height. that's why the position is changing and not the height.

 UIView.animateWithDuration(1, animations: {
 // Your problem is the line below
        self.SendButton.frame = CGRectMake(0, -340, UIScreen.mainScreen().applicationFrame.width, 30) 
    })

The function parameters of the function CGRectMake are
CGRectMake(xPosition, yPosition, width, height)

Change the code below to your desired height.

   UIView.animateWithDuration(1, animations: {
        self.SendButton.frame = CGRectMake(0, 0, UIScreen.mainScreen().applicationFrame.width, yourDesiredHeight) 
    })

But this doesn't help in changing the height of the input accessory once it was set.

First add a separate UIView as input accessory(with added height) and add the button into this UIView. Animate the button inside after that. This works. You can check out the code in the gist
https://gist.github.com/rakeshbs/539827925df923e41afe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!