Skip to content
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

Feature/#1 #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
7EB7B90329DF4A3600C2A7F6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB7B90229DF4A3600C2A7F6 /* AppDelegate.swift */; };
7EB7B90529DF4A3600C2A7F6 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB7B90429DF4A3600C2A7F6 /* SceneDelegate.swift */; };
7EB7B90729DF4A3600C2A7F6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB7B90629DF4A3600C2A7F6 /* ViewController.swift */; };
7EB7B90A29DF4A3600C2A7F6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7EB7B90829DF4A3600C2A7F6 /* Main.storyboard */; };
7EB7B90C29DF4A3A00C2A7F6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7EB7B90B29DF4A3A00C2A7F6 /* Assets.xcassets */; };
7EB7B90F29DF4A3A00C2A7F6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7EB7B90D29DF4A3A00C2A7F6 /* LaunchScreen.storyboard */; };
7EB7B91729DF54D300C2A7F6 /* NewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB7B91629DF54D300C2A7F6 /* NewViewController.swift */; };
7EB7B91929DF564F00C2A7F6 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB7B91829DF564F00C2A7F6 /* SecondViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
7EB7B8FF29DF4A3600C2A7F6 /* GO-SOPT-FIRST-SEMINAR.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "GO-SOPT-FIRST-SEMINAR.app"; sourceTree = BUILT_PRODUCTS_DIR; };
7EB7B90229DF4A3600C2A7F6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7EB7B90429DF4A3600C2A7F6 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
7EB7B90629DF4A3600C2A7F6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
7EB7B90929DF4A3600C2A7F6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
7EB7B90B29DF4A3A00C2A7F6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7EB7B90E29DF4A3A00C2A7F6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7EB7B91029DF4A3A00C2A7F6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7EB7B91629DF54D300C2A7F6 /* NewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewViewController.swift; sourceTree = "<group>"; };
7EB7B91829DF564F00C2A7F6 /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -59,10 +61,11 @@
7EB7B90229DF4A3600C2A7F6 /* AppDelegate.swift */,
7EB7B90429DF4A3600C2A7F6 /* SceneDelegate.swift */,
7EB7B90629DF4A3600C2A7F6 /* ViewController.swift */,
7EB7B90829DF4A3600C2A7F6 /* Main.storyboard */,
7EB7B90B29DF4A3A00C2A7F6 /* Assets.xcassets */,
7EB7B90D29DF4A3A00C2A7F6 /* LaunchScreen.storyboard */,
7EB7B91029DF4A3A00C2A7F6 /* Info.plist */,
7EB7B91629DF54D300C2A7F6 /* NewViewController.swift */,
7EB7B91829DF564F00C2A7F6 /* SecondViewController.swift */,
);
path = "GO-SOPT-FIRST-SEMINAR";
sourceTree = "<group>";
Expand Down Expand Up @@ -127,7 +130,6 @@
files = (
7EB7B90F29DF4A3A00C2A7F6 /* LaunchScreen.storyboard in Resources */,
7EB7B90C29DF4A3A00C2A7F6 /* Assets.xcassets in Resources */,
7EB7B90A29DF4A3600C2A7F6 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -141,20 +143,14 @@
7EB7B90729DF4A3600C2A7F6 /* ViewController.swift in Sources */,
7EB7B90329DF4A3600C2A7F6 /* AppDelegate.swift in Sources */,
7EB7B90529DF4A3600C2A7F6 /* SceneDelegate.swift in Sources */,
7EB7B91929DF564F00C2A7F6 /* SecondViewController.swift in Sources */,
7EB7B91729DF54D300C2A7F6 /* NewViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
7EB7B90829DF4A3600C2A7F6 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
7EB7B90929DF4A3600C2A7F6 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
7EB7B90D29DF4A3A00C2A7F6 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down Expand Up @@ -292,7 +288,6 @@
INFOPLIST_FILE = "GO-SOPT-FIRST-SEMINAR/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -320,7 +315,6 @@
INFOPLIST_FILE = "GO-SOPT-FIRST-SEMINAR/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
2 changes: 0 additions & 2 deletions GO-SOPT-FIRST-SEMINAR/GO-SOPT-FIRST-SEMINAR/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
Expand Down
161 changes: 161 additions & 0 deletions GO-SOPT-FIRST-SEMINAR/GO-SOPT-FIRST-SEMINAR/NewViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
//
// NewViewController.swift
// GO-SOPT-FIRST-SEMINAR
//
// Created by 김사랑 on 2023/04/07.
//

import UIKit

class NewViewController: UIViewController {

private let nameLabel: UILabel = {
let label = UILabel()
label.text = "이름이 무엇인가요🥸"
label.font = .boldSystemFont(ofSize: 20)
label.textColor = .black
label.textAlignment = .center
return label
}()

private let valueSlider: UISlider = {
let slider = UISlider()
slider.minimumValue = 0
slider.maximumValue = 100
slider.value = 50
slider.minimumTrackTintColor = .black
return slider
}()

private lazy var presentButton: UIButton = {
let button = UIButton()
button.setTitle("present", for: .normal)
button.backgroundColor = .black
button.layer.cornerRadius = 10
button.layer.shadowColor = UIColor.black.cgColor
button.layer.shadowOpacity = 0.4 //투명도
button.layer.shadowOffset = CGSize.zero //위치
button.layer.shadowRadius = 7 //반경

button.setTitleColor(.white, for: .normal)

button.addTarget(self,
action: #selector(presentButtonTapped),
for: .touchUpInside)

return button
}()

private lazy var pushButton: UIButton = {
let button = UIButton()
button.setTitle("push", for: .normal)
button.backgroundColor = .black
button.layer.cornerRadius = 10
button.layer.shadowColor = UIColor.black.cgColor
button.layer.shadowOpacity = 0.4 //투명도
button.layer.shadowOffset = CGSize.zero //위치
button.layer.shadowRadius = 7 //반경
button.setTitleColor(.white, for: .normal)

button.addTarget(self,
action: #selector(pushButtonTapped),
for: .touchUpInside)

return button
}()

private let nameTextField: UITextField = {
let textField = UITextField()
textField.placeholder = "이름을 적어주세요 :)"
textField.clearButtonMode = .whileEditing
textField.layer.borderColor = UIColor.black.cgColor
textField.layer.cornerRadius = 10
textField.layer.borderWidth = 0.1
textField.leftView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 15.0, height: 0.0)) //여백주기
textField.leftViewMode = .always

return textField
}()

override func viewDidLoad() {
super.viewDidLoad()

style()
setLayout()
// Do any additional setup after loading the view.
}



}

private extension NewViewController {

func style() {

view.backgroundColor = .white
}

func setLayout() {

[nameLabel, nameTextField,
presentButton, pushButton, valueSlider].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
view.addSubview($0)
}

NSLayoutConstraint.activate([nameLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 300),
nameLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
nameLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30)])

NSLayoutConstraint.activate([valueSlider.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 10),
valueSlider.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
valueSlider.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30)])

NSLayoutConstraint.activate([nameTextField.topAnchor.constraint(equalTo: valueSlider.bottomAnchor, constant: 10),
nameTextField.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
nameTextField.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
nameTextField.heightAnchor.constraint(equalToConstant: 48)])

NSLayoutConstraint.activate([presentButton.topAnchor.constraint(equalTo: nameTextField.bottomAnchor, constant: 20),
presentButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
presentButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
presentButton.heightAnchor.constraint(equalToConstant: 48)])

NSLayoutConstraint.activate([pushButton.topAnchor.constraint(equalTo: presentButton.bottomAnchor, constant: 20),
pushButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
pushButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
pushButton.heightAnchor.constraint(equalToConstant: 48)])
}

func presentToSecondViewController() {

let secondViewController = SecondViewController_1st_Seminar()
secondViewController.modalPresentationStyle = .fullScreen
self.present(secondViewController, animated: true)
}

func pushToSecondViewController() {

let secondViewController = SecondViewController_1st_Seminar()
if let name = nameTextField.text{
secondViewController.dataBind(name: name)
}
self.navigationController?.pushViewController(secondViewController, animated: true)
}

@objc
func presentButtonTapped() {

presentToSecondViewController()
}

@objc
func pushButtonTapped() {

pushToSecondViewController()
}



}
50 changes: 12 additions & 38 deletions GO-SOPT-FIRST-SEMINAR/GO-SOPT-FIRST-SEMINAR/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,19 @@
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?



func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.

// 1.
guard let windowScene = (scene as? UIWindowScene) else { return }
// 2.
self.window = UIWindow(windowScene: windowScene)
// 3.
let navigationController = UINavigationController(rootViewController: NewViewController())
self.window?.rootViewController = navigationController
// 4.
self.window?.makeKeyAndVisible()
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// SecondViewController.swift
// GO-SOPT-FIRST-SEMINAR
//
// Created by 김사랑 on 2023/04/07.
//

import UIKit

final class SecondViewController_1st_Seminar: UIViewController {

private let nameLabel: UILabel = {
let label = UILabel()
label.text = "반가워요!"
label.font = .boldSystemFont(ofSize: 20)
return label
}()

private lazy var backButton: UIButton = {
let button = UIButton()
button.setTitle("뒤로가기", for: .normal)
button.setTitleColor(.blue, for: .normal)
button.titleLabel?.font = .boldSystemFont(ofSize: 20)

button.addTarget(self,
action: #selector(backButtonTapped),
for: .touchUpInside)

return button
}()

override func viewDidLoad() {
super.viewDidLoad()

style()
setLayout()

}

func dataBind(name: String) {
nameLabel.text = name
}


}

private extension SecondViewController_1st_Seminar {

func style() {

view.backgroundColor = .white
}

func setLayout() {

[nameLabel, backButton].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
view.addSubview($0)
}

NSLayoutConstraint.activate([nameLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
nameLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor)])


NSLayoutConstraint.activate([backButton.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 20),
backButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
backButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
backButton.heightAnchor.constraint(equalToConstant: 48)])
}

@objc
func backButtonTapped() {

if self.navigationController == nil {
self.dismiss(animated: true, completion: nil)
} else {
self.navigationController?.popViewController(animated: true)
}
}



}
Loading