Tre*_*ler 0 uiviewanimation ios swift
我在 UIView 中有一个文本字段,我想在用户访问该 VC 时将其滑入。这容易实现吗?如果是这样,我该怎么做?
这是一个快速示例:
import UIKit
class ViewController: UIViewController {
    var textField: UITextField?
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    override func viewDidAppear(_ animated: Bool) {
        let textFieldFrame = CGRect(x: -200, y: 20, width: 200, height: 30)
        let textField = UITextField(frame: textFieldFrame)
        textField.placeholder = "Some Text"
        self.textField = textField
        self.view.addSubview(self.textField!)
        UIView.animate(
            withDuration: 0.4,
            delay: 0.0,
            options: .curveLinear,
            animations: {
                self.textField?.frame.origin.x = 100
        }) { (completed) in
        }
    }
}
| 归档时间: | 
 | 
| 查看次数: | 6754 次 | 
| 最近记录: |