两个视图的动画问题

时间:2015-01-04 20:07:27

标签: ios swift

我有一个动画,当我按下UIButton按钮的尺寸被切成两半时,按钮会进一步移动到视图的左侧。当按钮是动画时,一个UITextField不在视图之外,并且最初无法看到,会被转换为视图。但是,当我按下UITextField开始输入时,按钮会返回到原始位置,动画开始前设置的位置,按钮的尺寸保持不变。但是UITextField从视图中消失了。我怎样才能使UIButton保持在左侧的位置,并使UITextField不再消失。我使用了以下代码:

@IBAction func joinCircleButton(sender: AnyObject) {
    let button = sender as UIButton
    joinTextField.frame.origin.x=500
    joinTextField.frame.origin.y=100
    if (button.frame.origin.x - 75>0){
    UIView.animateWithDuration(0.5, animations:{
        button.frame = CGRectMake(button.frame.origin.x - 125, button.frame.origin.y,button.frame.size.width, button.frame.size.height)
        button.transform = CGAffineTransformMakeScale(0.5, 0.5);
        self.joinTextField.frame=CGRectMake(self.joinTextField.frame.origin.x - 325, self.joinTextField.frame.origin.y,self.joinTextField.frame.size.width, self.joinTextField.frame.size.height)

    })
    }
}
override func viewDidLayoutSubviews(){
    joinTextField.center = CGPointMake(joinTextField.frame.origin.x-500, joinTextField.frame.origin.y)


}

0 个答案:

没有答案