-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1차 세미나 과제 해결 #2
base: main
Are you sure you want to change the base?
1차 세미나 과제 해결 #2
Changes from all commits
f913615
e471920
347de92
50c2188
2d2f232
35cb68f
3ff6023
c06a2a6
c73ad67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "key.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Logo.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "mail.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Extension.swift | ||
// sopt33-first-seminar | ||
// | ||
// Created by 티모시 킴 on 10/11/23. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIImage { | ||
|
||
// 이미지를 원하는 크기로 조정하는 메서드 | ||
func resizeImageTo(size: CGSize) -> UIImage? { | ||
UIGraphicsBeginImageContextWithOptions(size, false, 0.0) | ||
self.draw(in: CGRect(origin: CGPoint.zero, size: size)) | ||
guard let resizedImage = UIGraphicsGetImageFromCurrentImageContext() else { | ||
return nil | ||
} | ||
UIGraphicsEndImageContext() | ||
return resizedImage | ||
} | ||
|
||
} | ||
|
||
extension UITextField { | ||
|
||
// 텍스트필드의 왼쪽에 이미지를 배치하는 메서드 | ||
func addLeftImage(image : UIImage){ | ||
let imageView = UIImageView(frame: CGRect(x: 10, y: 0, width: image.size.width, height: image.size.height)) | ||
let view = UIView(frame: CGRect(x: 0, y: 0, width: image.size.width + 20, height: image.size.height)) | ||
imageView.image = image | ||
view.addSubview(imageView) | ||
self.leftView = view | ||
self.leftViewMode = .always | ||
} | ||
|
||
Comment on lines
+1
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extension 으로 구현해서 재사용 가능한점 너무 좋습니다! |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,18 @@ class ResultVC: UIViewController { | |
var loginDataCompletion: ((([String]) -> Void)?) // 매개변수 타입: String 배열, 리턴타입: void | ||
|
||
@IBOutlet weak var emailLabel: UILabel! | ||
@IBOutlet weak var passwordLabel: UILabel! | ||
@IBOutlet weak var backButton: UIButton! | ||
|
||
func setViewStyle() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 가볍게 setStyle() 을 함수명으로 쓰기도 합니다! func setUI() {
setStyle()
setLayout()
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그리고 setUI를 viewDidLoad() 안에 넣습니다 |
||
emailLabel.font = UIFont(name: "SnellRoundhand-Bold", size: 23.0) | ||
|
||
backButton.layer.cornerRadius = 5 | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
bindText() | ||
setViewStyle() | ||
} | ||
|
||
// MARK: 화면전환 방식1 - NavigationController (pop) | ||
|
@@ -42,8 +49,7 @@ class ResultVC: UIViewController { | |
} | ||
|
||
private func bindText() { | ||
self.emailLabel.text = "email : \(email)" | ||
self.passwordLabel.text = "password : \(password)" | ||
emailLabel.text = "\(email)" | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,24 @@ class ViewController: UIViewController { | |
private var idText: String = "" | ||
private var passwordText: String = "" | ||
|
||
@IBOutlet weak var idTextField: UITextField! | ||
@IBOutlet weak var passwordTextField: UITextField! | ||
@IBOutlet weak var loginButton: UIButton! | ||
|
||
func setViewStyle() { | ||
idTextField.addLeftImage(image: (UIImage(named: "Mail")?.resizeImageTo(size: CGSize(width: 25, height: 25)))!) | ||
idTextField.clearButtonMode = .whileEditing | ||
|
||
passwordTextField.addLeftImage(image: (UIImage(named: "Key")?.resizeImageTo(size: CGSize(width: 25, height: 25)))!) | ||
passwordTextField.clearButtonMode = .whileEditing | ||
passwordTextField.isSecureTextEntry = true | ||
|
||
loginButton.layer.cornerRadius = 5 | ||
} | ||
|
||
Comment on lines
+19
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 레아아웃에 대한 코드를 따로 함수로 구현하셨네요! 너무 좋은 방법입니다!! |
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setViewStyle() | ||
} | ||
|
||
@IBAction func idTextFieldDidEditing(_ sender: Any) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extension을 파일로 따로 빼서 쓰는 경우
UIImage+.swift 파일과 UITextField+.swift 파일로 나누어서 작성해도 좋을 것 같아요~~
대체로 extension 파일의 경우
어쩌고+.swift 혹은 어쩌고+extension.swift 등의 파일명을 사용합니다!