cmd + k
์๋ฎฌ๋ ์ดํฐ์์ ์๋์ผ๋ก ํค๋ณด๋๊ฐ ์ฌ๋ผ ์ค์ง ์๋๋ค.
๋ฐ๋ผ์ ์ค์ ์ ๋ฐ๋ก ํด์ค์ผ ํ๋ค.
Toggle Software Keyboard ๋ฅผ ํ์ฑํ ํด์ฃผ๋ฉด ๋!
import UIKit
import SnapKit
class MainViewController: UIViewController {
var textField = UITextField()
var doneButton = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.gray
configure()
}
private func configure() {
[textField, doneButton].forEach {view.addSubview($0)}
//textField ์ค์
textField.keyboardType = UIKeyboardType.emailAddress //ํ
์คํธํ๋์ ์
๋ ฅํ ํค๋ณด๋ ์คํ์ผ
textField.placeholder = "์ด๋ฉ์ผ ์
๋ ฅ"
textField.borderStyle = .roundedRect //ํ
์คํธํ๋ ์
textField.clearButtonMode = .always //์
๋ ฅํ ๋ด์ฉ ์ทจ์ ๋ฒํผ ์์ฑ
textField.returnKeyType = .search //ํค๋ณด๋์์ ์ํฐ ๋ถ๋ถ ์ด๋ฆ ๋ฐ๊พธ๊ธฐ
//doneButton ์ค์
doneButton.setTitle("Done", for: .normal)
doneButton.backgroundColor = .systemBlue
//textField ์คํ ๋ ์ด์์
textField.snp.makeConstraints {
$0.top.equalToSuperview().inset(200)
$0.leading.equalToSuperview().inset(20)
$0.width.equalTo(250)
}
//doneButton ์คํ ๋ ์ด์์
doneButton.snp.makeConstraints {
$0.top.equalTo(textField)
$0.leading.equalTo(textField.snp.trailing).offset(20)
$0.width.equalTo(60)
}
}
}
ํ ์ด๋ธ๋ทฐ ์ ์ ์ฌ์ฌ์ฉ ๋จ - ๋ธ๋ก๊ทธ ์ถ๊ฐ ์์ฑํ๊ธฐ (0) | 2024.07.28 |
---|---|
[UIKit] ViewController ์๋ช ์ฃผ๊ธฐ(Life Cycle) (0) | 2024.07.10 |
[iOS] toast message - ๋ฐฐ๋ฌ์ ๋ฏผ์กฑ ์ฅ๋ฐ๊ตฌ๋์ ์ถ๊ฐ๋์ต๋๋ค (0) | 2024.07.07 |
[iOS] Lottie ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น๋ฐฉ๋ฒ - ๋ฐ์น์คํฌ๋ฆฐ ๋ง๋ค๊ธฐ_์ฝ๋๋ฒ ์ด์ค (0) | 2024.07.05 |
[UIKit] UITableView ์ฝ๋๋ฒ ์ด์ค ์ฌ์ฉ๋ฒ (0) | 2024.07.04 |