Skip to content
Open
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
62 changes: 48 additions & 14 deletions Week 5/Shimmy/week5-mission/week5-mission.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
03887C312AE7919F008C0635 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03887C302AE7919F008C0635 /* AppDelegate.swift */; };
03887C332AE7919F008C0635 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03887C322AE7919F008C0635 /* SceneDelegate.swift */; };
03887C352AE7919F008C0635 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03887C342AE7919F008C0635 /* ViewController.swift */; };
03887C382AE7919F008C0635 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 03887C362AE7919F008C0635 /* Main.storyboard */; };
03887C3A2AE791A0008C0635 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 03887C392AE791A0008C0635 /* Assets.xcassets */; };
03887C3D2AE791A0008C0635 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 03887C3B2AE791A0008C0635 /* LaunchScreen.storyboard */; };
03887C482AE791A0008C0635 /* week5_missionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03887C472AE791A0008C0635 /* week5_missionTests.swift */; };
03887C522AE791A0008C0635 /* week5_missionUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03887C512AE791A0008C0635 /* week5_missionUITests.swift */; };
03887C542AE791A0008C0635 /* week5_missionUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03887C532AE791A0008C0635 /* week5_missionUITestsLaunchTests.swift */; };
03EABFFB2AEF95AA00C80B72 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EABFFA2AEF95AA00C80B72 /* MainViewController.swift */; };
03EABFFD2AF02E2900C80B72 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EABFFC2AF02E2900C80B72 /* MenuViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -40,7 +41,6 @@
03887C302AE7919F008C0635 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
03887C322AE7919F008C0635 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
03887C342AE7919F008C0635 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
03887C372AE7919F008C0635 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
03887C392AE791A0008C0635 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
03887C3C2AE791A0008C0635 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
03887C3E2AE791A0008C0635 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -49,6 +49,8 @@
03887C4D2AE791A0008C0635 /* week5-missionUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "week5-missionUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
03887C512AE791A0008C0635 /* week5_missionUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = week5_missionUITests.swift; sourceTree = "<group>"; };
03887C532AE791A0008C0635 /* week5_missionUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = week5_missionUITestsLaunchTests.swift; sourceTree = "<group>"; };
03EABFFA2AEF95AA00C80B72 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
03EABFFC2AF02E2900C80B72 /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -102,10 +104,11 @@
03887C302AE7919F008C0635 /* AppDelegate.swift */,
03887C322AE7919F008C0635 /* SceneDelegate.swift */,
03887C342AE7919F008C0635 /* ViewController.swift */,
03887C362AE7919F008C0635 /* Main.storyboard */,
03887C392AE791A0008C0635 /* Assets.xcassets */,
03887C3B2AE791A0008C0635 /* LaunchScreen.storyboard */,
03887C3E2AE791A0008C0635 /* Info.plist */,
03FBD2BF2AF0C736002C459B /* Main */,
03FBD2BB2AF0C6DC002C459B /* Menu */,
);
path = "week5-mission";
sourceTree = "<group>";
Expand All @@ -127,6 +130,46 @@
path = "week5-missionUITests";
sourceTree = "<group>";
};
03FBD2BB2AF0C6DC002C459B /* Menu */ = {
isa = PBXGroup;
children = (
03FBD2BE2AF0C6F4002C459B /* ViewController */,
03FBD2BC2AF0C6E4002C459B /* View */,
);
path = Menu;
sourceTree = "<group>";
};
03FBD2BC2AF0C6E4002C459B /* View */ = {
isa = PBXGroup;
children = (
);
path = View;
sourceTree = "<group>";
};
03FBD2BE2AF0C6F4002C459B /* ViewController */ = {
isa = PBXGroup;
children = (
03EABFFC2AF02E2900C80B72 /* MenuViewController.swift */,
);
path = ViewController;
sourceTree = "<group>";
};
03FBD2BF2AF0C736002C459B /* Main */ = {
isa = PBXGroup;
children = (
03FBD2C02AF0C740002C459B /* ViewController */,
);
path = Main;
sourceTree = "<group>";
};
03FBD2C02AF0C740002C459B /* ViewController */ = {
isa = PBXGroup;
children = (
03EABFFA2AEF95AA00C80B72 /* MainViewController.swift */,
);
path = ViewController;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -233,7 +276,6 @@
files = (
03887C3D2AE791A0008C0635 /* LaunchScreen.storyboard in Resources */,
03887C3A2AE791A0008C0635 /* Assets.xcassets in Resources */,
03887C382AE7919F008C0635 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -259,8 +301,10 @@
buildActionMask = 2147483647;
files = (
03887C352AE7919F008C0635 /* ViewController.swift in Sources */,
03EABFFD2AF02E2900C80B72 /* MenuViewController.swift in Sources */,
03887C312AE7919F008C0635 /* AppDelegate.swift in Sources */,
03887C332AE7919F008C0635 /* SceneDelegate.swift in Sources */,
03EABFFB2AEF95AA00C80B72 /* MainViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -297,14 +341,6 @@
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
03887C362AE7919F008C0635 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
03887C372AE7919F008C0635 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
03887C3B2AE791A0008C0635 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down Expand Up @@ -442,7 +478,6 @@
INFOPLIST_FILE = "week5-mission/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 @@ -470,7 +505,6 @@
INFOPLIST_FILE = "week5-mission/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "FCCD2C6A-2B6E-4111-B636-96DF813F7761"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"filename" : "INHA-UMC-5th.png",
"idiom" : "iphone",
"scale" : "1x"
},
{
"idiom" : "iphone",
"scale" : "2x"
},
{
"idiom" : "iphone",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
//
// MainViewController.swift
// week5-mission
//
// Created by Seungbo Shim on 2023/10/30.
//

import UIKit
import SwiftUI

class MainViewController: UIViewController {
// MARK: - Components
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.text = "INHA"
label.textAlignment = .center
label.font = UIFont.systemFont(ofSize: 28)
label.textColor = .black
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
return label
}()

private lazy var subTitleLabel: UILabel = {
let label = UILabel()
label.text = "UMC"
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 56)
label.textColor = .black
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

private lazy var logoView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "INHA-UMC-5th")
imageView.layer.cornerRadius = 100

imageView.clipsToBounds = true
// cornerRadius 적용시 추가

//imageView.layer.masksToBounds = false
// 이건 shadow 같이쓸때 추가
// 이걸 뒤에 선언하니까 clipsToBounds가 묻힘
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()

private lazy var loginLabel: UILabel = {
let label = UILabel()
label.text = "Sign up or log in"
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 24)
label.textColor = .black
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

private lazy var AppleButton: UIButton = {
let button = UIButton()
button.setTitle("Continue with Apple", for: .normal)
button.setTitleColor(.black, for: .normal)
button.backgroundColor = .white
button.addTarget(self, action: #selector(appleButtonTapped), for: .touchUpInside)
button.layer.borderColor = CGColor(red: 0, green: 0, blue: 0, alpha: 1)
button.layer.borderWidth = 2.0
button.layer.cornerRadius = 6
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()

private lazy var GoogleButton: UIButton = {
let button = UIButton()
button.setTitle("Continue with Google", for: .normal)
button.setTitleColor(.black, for: .normal)
button.backgroundColor = .white
button.addTarget(self, action: #selector(googleButtonTapped), for: .touchUpInside)
button.layer.borderColor = CGColor(red: 0, green: 0, blue: 0, alpha: 1)
button.layer.borderWidth = 2.0
button.layer.cornerRadius = 6
button.translatesAutoresizingMaskIntoConstraints = false
return button
}()

@objc func appleButtonTapped() {
print("Apple login")
}

@objc func googleButtonTapped() {
print("Google login")
}

// MARK: - Life cycle
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setupUI()
}

// MARK: - Set up
private func setupUI() {
self.view.backgroundColor = .white
// self.view 는 전체 view(부모)
// 전체 view에 각각의 view를 추가
// 추가한 순서대로 z 값이 정해짐 (나중에 넣은 black이 제일 위로 감)
self.view.addSubview(titleLabel)
self.view.addSubview(subTitleLabel)
self.view.addSubview(logoView)
self.view.addSubview(loginLabel)
self.view.addSubview(AppleButton)
self.view.addSubview(GoogleButton)
// 각각 뷰에 오토레이아웃 함수 호출
setTitleLabelLayout()
setSubTitleLabelLayout()
setLogoViewLayout()
setLoginLabelLayout()
setAppleButtonLayout()
setGoogleButtonLayout()
}

private func setTitleLabelLayout() {
let titleLabelConstraint = [
self.titleLabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
self.titleLabel.bottomAnchor.constraint(equalTo: self.subTitleLabel.topAnchor),
]
NSLayoutConstraint.activate(titleLabelConstraint)
}

private func setSubTitleLabelLayout() {
let subTitleLabelConstraint = [
self.subTitleLabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
//self.subTitleLabel.topAnchor.constraint(equalTo: self.titleLabel.bottomAnchor),
self.subTitleLabel.bottomAnchor.constraint(equalTo: self.logoView.topAnchor, constant: -80)
]
NSLayoutConstraint.activate(subTitleLabelConstraint)
}

private func setLogoViewLayout() {
let logoViewConstant = [
self.logoView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
self.logoView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
self.logoView.widthAnchor.constraint(equalToConstant: 200),
self.logoView.heightAnchor.constraint(equalToConstant: 200),
]
NSLayoutConstraint.activate(logoViewConstant)
}

private func setLoginLabelLayout() {
let loginLabelConstraint = [
self.loginLabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
self.loginLabel.topAnchor.constraint(equalTo: self.logoView.bottomAnchor, constant: 80),
]
NSLayoutConstraint.activate(loginLabelConstraint)
}

private func setAppleButtonLayout() {
let appleButtonConstraint = [
self.AppleButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
self.AppleButton.widthAnchor.constraint(equalTo: self.view.widthAnchor, constant: -50),
self.AppleButton.topAnchor.constraint(equalTo: self.loginLabel.bottomAnchor, constant: 20)
]
NSLayoutConstraint.activate(appleButtonConstraint)
}

private func setGoogleButtonLayout() {
let googleButtonConstraint = [
self.GoogleButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
self.GoogleButton.widthAnchor.constraint(equalTo: self.view.widthAnchor, constant: -50),
self.GoogleButton.topAnchor.constraint(equalTo: self.AppleButton.bottomAnchor, constant: 10)
]
NSLayoutConstraint.activate(googleButtonConstraint)
}
}

// MARK: - Extension
extension UIImage {
// UIButton에 UIImage를 넣을 때, 이미지의 크기를 조정하는 함수
func resizeImage(image: UIImage, toSize size: CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
image.draw(in: CGRect(origin: CGPoint.zero, size: size))
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return resizedImage
}

// UIImage의 cornerRadius를 설정할 수 있도록 해주는 함수
func setCornerRadius(with radius: CGFloat) -> UIImage {
let format = UIGraphicsImageRendererFormat()
format.scale = scale
let renderer = UIGraphicsImageRenderer(size: size, format: format)
return renderer.image { rendererContext in
let rect = CGRect(origin: .zero, size: size)
let path = UIBezierPath(roundedRect: rect,
byRoundingCorners: .allCorners,
cornerRadii: CGSize(width: radius, height: radius))
path.close()

let cgContext = rendererContext.cgContext
cgContext.saveGState()
path.addClip()
draw(in: rect)
cgContext.restoreGState()
}
}
}


@available(iOS 13.0.0, *)
struct MainViewControllerPreview: PreviewProvider {
static var previews: some View {
MainViewController().toPreview()
}
}
Loading