@IBOutlet var Button: [UIButton]!
func RoundBtn(){
for btn in Button{
btn.layer.cornerRadius = 39
btn.layer.masksToBounds = true
}
}
스토리보드 안 텍스트 필드를 클릭 -> 5번째 아이콘 클릭 -> Clear Button을 Appears while editing으로 변경한 후, Clear when editing begins 클릭!
self.emailLabel.layer.cornerRadius = 18
self.pwLabel.layer.cornerRadius = 18
emailLabel.layer.masksToBounds = true
pwLabel.layer.masksToBounds = true
extension UIButton {
func underline() {
guard let text = self.titleLabel?.text else { return }
let attributedString = NSMutableAttributedString(string: text)
//NSAttributedStringKey.foregroundColor : UIColor.blue
attributedString.addAttribute(NSAttributedString.Key.underlineColor, value: self.titleColor(for: .normal)!, range: NSRange(location: 0, length: text.count))
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: self.titleColor(for: .normal)!, range: NSRange(location: 0, length: text.count))
attributedString.addAttribute(NSAttributedString.Key.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: NSRange(location: 0, length: text.count))
self.setAttributedTitle(attributedString, for: .normal)
}
}
// viewDidLoad에 addKeyboardObserver() 적기!
// UITextFieldDelegate 생성하기
// viewDidLoad함수안에
// emailTextField.delegate = self
// pwTextField.delegate = self
extension LoginViewController: UITextFieldDelegate {
private func addKeyboardObserver() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
private func closeKeyboardObserver(){
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}
@objc func keyboardWillShow(_ notification: Notification) {
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double
let curve = notification.userInfo?[UIResponder.keyboardAnimationCurveUserInfoKey] as! UInt
UIView.animate(withDuration: duration, delay: 0, options: .init(rawValue: curve), animations: {
self.backgroundView.transform = .init(translationX: 0, y: -80)
})
}
@objc func keyboardWillHide(_ notification: Notification) {
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double
let curve = notification.userInfo?[UIResponder.keyboardAnimationCurveUserInfoKey] as! UInt
UIView.animate(withDuration: duration, delay: 0, options: .init(rawValue: curve), animations: {
self.backgroundView.transform = .identity
})
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
}
뷰컨트롤러의 생명주기: viewDidLoad -> viewWillAppear -> viewDidAppear -> viewWillDisappear -> viewDidDisappear
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
self.friendTableView.separatorStyle = UITableViewCell.SeparatorStyle.none
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath){
if(editingStyle == .delete){
friendInformations.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .bottom)
}
}