ios – I don’t want the view places that change when I click on the textfield to return to their original places when I write something on the textfield

0
49


When I write on the textfield, the views that go to the specified place in the background are automatically restored.

import UIKit
import Foundation
class LoginTestViewController: UIViewController, UITextFieldDelegate { 
@IBOutlet weak var whiteView: UIView!
@IBOutlet weak var aquaView: UIView!
@IBOutlet weak var blueView: UIView!
@IBOutlet weak var redView: UIView!
@IBOutlet weak var mailView: UIView!
@IBOutlet weak var passwordView: UIView!
@IBOutlet weak var mailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var loginView: UIView!
@IBOutlet weak var mailButton: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()
    self.mailTextField.delegate = self
    self.passwordTextField.delegate = self
    self.whiteView.layer.cornerRadius = self.whiteView.frame.height / 2
    self.aquaView.layer.cornerRadius = self.aquaView.frame.height / 2
    self.blueView.layer.cornerRadius = self.blueView.frame.height / 2
    self.redView.layer.cornerRadius = self.redView.frame.height / 2
    self.mailTextField.addDoneButtonOnKeyboard()
    self.passwordTextField.addDoneButtonOnKeyboard()
    self.mailTextField.attributedPlaceholder = NSAttributedString(string: "Kullanıcı Adı", attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])
    self.passwordTextField.attributedPlaceholder = NSAttributedString(string: "Şifre", attributes: [NSAttributedString.Key.foregroundColor: UIColor.white])
    NotificationCenter.default.addObserver(self, selector: #selector(LoginTestViewController.keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
    NotificationCenter.default.addObserver(self, selector: #selector(LoginTestViewController.keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
    
    self.hideKeyboardWhenTappedAround()
    
}

override func viewWillDisappear(_ animated: Bool) {
    
    NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
    NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
    
}

@objc func keyboardWillShow() {
    
    self.aquaView.frame.origin = CGPoint(x: -244, y: -527)
    self.blueView.frame = CGRect(x: -221, y: -187, width: self.blueView.frame.size.width, height: self.blueView.frame.size.height )
    self.redView.frame = CGRect(x: -86, y: 239, width: self.redView.frame.size.width, height: self.redView.frame.size.height )
    self.loginView.frame.origin.y = -100

    
}
@objc func keyboardWillHide() {
    
    
    self.aquaView.frame = CGRect(x: -27, y: -258, width: self.aquaView.frame.size.width, height: self.aquaView.frame.size.height)
    self.blueView.frame = CGRect(x: -312, y: -50, width: self.blueView.frame.size.width, height: self.blueView.frame.size.height)
    self.redView.frame = CGRect(x: -182, y: 246, width: self.redView.frame.size.width, height: self.redView.frame.size.height)
    self.loginView.frame.origin.y = 0

}

}
The first picture is when ı open the app show us
enter image description here

When I click on the second image textfield, the keyboard appears and the views in the background change.
enter image description here

In the 3rd image, when I write something in the texfield, the back views come back to their original place but ı dont want that. when i close the keyboard i want it to be like in the 1st photo
enter image description here