Commit 1f9a339d authored by oYasuiHaruki's avatar oYasuiHaruki

initial commit

parent 652bc93a
Pipeline #35398357 failed with stages
in 1 minute and 15 seconds
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
......@@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>practiceUITextFieldEditingChanged.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
......@@ -9,12 +9,68 @@
import UIKit
class ViewController: UIViewController {
let vietnamTextField: UITextField = {
let tf = UITextField()
tf.translatesAutoresizingMaskIntoConstraints = false
tf.placeholder = "vietnam"
tf.font = UIFont.systemFont(ofSize: 30)
tf.textAlignment = .center
tf.backgroundColor = .red
tf.keyboardType = .numberPad
tf.keyboardAppearance = UIKeyboardAppearance.dark
tf.addTarget(self, action: #selector(exchangeMoney(_:)), for: UIControl.Event.editingChanged)
tf.tag = 1
return tf
}()
let japanTextField: UITextField = {
let tf = UITextField()
tf.translatesAutoresizingMaskIntoConstraints = false
tf.placeholder = "japan"
tf.font = UIFont.systemFont(ofSize: 30)
tf.textAlignment = .center
tf.backgroundColor = .blue
tf.keyboardType = .numberPad
tf.keyboardAppearance = UIKeyboardAppearance.dark
tf.addTarget(self, action: #selector(exchangeMoney(_:)), for: UIControl.Event.editingChanged)
tf.tag = 2
return tf
}()
@objc func exchangeMoney(_ sender: UIButton) {
print("selected")
if sender.tag == 1 {
guard let vietnamMoney = Int(vietnamTextField.text ?? "") else { return }
let japanMoney = vietnamMoney / 208
japanTextField.text = "\(japanMoney)"
print(japanMoney)
} else if sender.tag == 2 {
guard let japanMoney = Int(japanTextField.text ?? "") else { return }
let vietnamMoney = japanMoney * 208
vietnamTextField.text = "\(vietnamMoney)"
print(vietnamMoney)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
setupViews()
}
func setupViews() {
self.view.addSubview(vietnamTextField)
vietnamTextField.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 30).isActive = true
vietnamTextField.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
vietnamTextField.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -50).isActive = true
vietnamTextField.heightAnchor.constraint(equalToConstant: 300).isActive = true
self.view.addSubview(japanTextField)
japanTextField.topAnchor.constraint(equalTo: vietnamTextField.bottomAnchor, constant: 30).isActive = true
japanTextField.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
japanTextField.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -50).isActive = true
japanTextField.heightAnchor.constraint(equalToConstant: 300).isActive = true
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment