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/guide view #6

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[Feat] #1 navigationBar 추가
  • Loading branch information
chaentopia committed Nov 25, 2022
commit 349538e0f6bd2453414dd4239fd0ba3ed1c4ef6d
4 changes: 4 additions & 0 deletions KorailTalk/KorailTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
C359FDC6292760440089DE21 /* GuideThirdViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C359FDC5292760440089DE21 /* GuideThirdViewController.swift */; };
C359FDC8292761340089DE21 /* GuideFourthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C359FDC7292761340089DE21 /* GuideFourthViewController.swift */; };
C36B59842927635F00C4CBEF /* GuideFifthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C36B59832927635F00C4CBEF /* GuideFifthViewController.swift */; };
C3A707EF2930696400BC0856 /* GuideNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A707EE2930696400BC0856 /* GuideNavigationBar.swift */; };
C3ACD64D2922897300128AA1 /* GuideFirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3ACD64C2922897300128AA1 /* GuideFirstViewController.swift */; };
/* End PBXBuildFile section */

@@ -35,6 +36,7 @@
C359FDC5292760440089DE21 /* GuideThirdViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideThirdViewController.swift; sourceTree = "<group>"; };
C359FDC7292761340089DE21 /* GuideFourthViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideFourthViewController.swift; sourceTree = "<group>"; };
C36B59832927635F00C4CBEF /* GuideFifthViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideFifthViewController.swift; sourceTree = "<group>"; };
C3A707EE2930696400BC0856 /* GuideNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideNavigationBar.swift; sourceTree = "<group>"; };
C3ACD64C2922897300128AA1 /* GuideFirstViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuideFirstViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

@@ -131,6 +133,7 @@
C359FDC5292760440089DE21 /* GuideThirdViewController.swift */,
C359FDC7292761340089DE21 /* GuideFourthViewController.swift */,
C36B59832927635F00C4CBEF /* GuideFifthViewController.swift */,
C3A707EE2930696400BC0856 /* GuideNavigationBar.swift */,
);
path = Guide;
sourceTree = "<group>";
@@ -223,6 +226,7 @@
C359FDC6292760440089DE21 /* GuideThirdViewController.swift in Sources */,
C3ACD64D2922897300128AA1 /* GuideFirstViewController.swift in Sources */,
C359FDC8292761340089DE21 /* GuideFourthViewController.swift in Sources */,
C3A707EF2930696400BC0856 /* GuideNavigationBar.swift in Sources */,
B1C2F184291F8CE8006F5E8A /* TabbarViewController.swift in Sources */,
C36B59842927635F00C4CBEF /* GuideFifthViewController.swift in Sources */,
);
53 changes: 46 additions & 7 deletions KorailTalk/KorailTalk/Guide/GuideFifthViewController.swift
Original file line number Diff line number Diff line change
@@ -93,14 +93,53 @@ class GuideFifthViewController: UIViewController {
super.viewDidLoad()
view.backgroundColor = .white
layout()
self.setNavigationBar()
}
private func setNavigationBar() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 36))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 199, height: 29))


topTitle.numberOfLines = 1
topTitle.textAlignment = .center
topTitle.font = .systemFont(ofSize: 24, weight: .semibold)
topTitle.textColor = .white
topTitle.text = "내일로 두번째 이야기"

let backBarButtonItem = UIBarButtonItem(
// image: UIImage(named:"button_back"),
title: "",
style: .plain,
target: self,
action: #selector(backTapped))
backBarButtonItem.tintColor = .white
self.navigationItem.backBarButtonItem = backBarButtonItem


containerView.addSubview(topTitle)

self.navigationItem.titleView = containerView
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.barTintColor = .systemCyan

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance

self.navigationController?.navigationBar.isTranslucent = false



}
@objc func backTapped(sender: UIBarButtonItem) {
navigationController?.popViewController(animated: false)
}


// private func setNavigationBar() {
// navigationController?.navigationBar.barTintColor = 0x0B4199.color
// navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
// navigationController?.navigationBar.shadowImage = UIImage()
//
// }
}

extension GuideFifthViewController {
@@ -112,7 +151,7 @@ extension GuideFifthViewController {
}

guideLabel.snp.makeConstraints{ make in
make.top.equalToSuperview().offset(156)
make.top.equalToSuperview().offset(48)
make.leading.equalTo(self.view.safeAreaLayoutGuide).offset(37)
}
titleLabel.snp.makeConstraints{ make in
66 changes: 57 additions & 9 deletions KorailTalk/KorailTalk/Guide/GuideFirstViewController.swift
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ class GuideFirstViewController: UIViewController {
return label
}()

private let rightButton : UIButton = {
lazy var rightButton : UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "button_right"), for: .normal)
button.addTarget(self, action: #selector(touchupNextButton), for: .touchUpInside)
@@ -87,35 +87,83 @@ class GuideFirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white

layout()
self.setNavigationBar()
// self.navigationController?.isNavigationBarHidden = false
// addNaviBar()

}

override func viewWillAppear(_ animated : Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.barStyle = .black
}



private func setNavigationBar() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 36))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 18))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 199, height: 29))


topTitle.numberOfLines = 1
topTitle.textAlignment = .center
topTitle.font = .systemFont(ofSize: 15)
topTitle.font = .systemFont(ofSize: 24, weight: .semibold)
topTitle.textColor = .white
topTitle.text = "내일로 두번째 이야기"

let backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: #selector(backTapped))
backBarButtonItem.tintColor = .red

let backBarButtonItem = UIBarButtonItem(
// image: UIImage(named:"button_back"),
title: "",
style: .plain,
target: self,
action: #selector(backTapped))
backBarButtonItem.tintColor = .white
self.navigationItem.backBarButtonItem = backBarButtonItem



containerView.addSubview(topTitle)

self.navigationItem.titleView = containerView
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = .systemCyan
self.navigationController?.navigationBar.barTintColor = 0x0B4199.color
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance

self.navigationController?.navigationBar.isTranslucent = false



}
@objc func backTapped(sender: UIBarButtonItem) {
navigationController?.popViewController(animated: false)
}

// private func addNaviBar() {
//
// // safe area
// var statusBarHeight: CGFloat = 0
// statusBarHeight = UIApplication.shared.windows.first?.safeAreaInsets.top ?? 0
//
// // navigationBar
// let naviBar = UINavigationBar(frame: .init(x: 0, y: statusBarHeight, width: view.frame.width, height: statusBarHeight))
// naviBar.isTranslucent = false
// naviBar.backgroundColor = .systemBlue
// naviBar.barTintColor = .systemBlue
//
// let naviItem = UINavigationItem(title: "내일로 두번째 이야기")
// naviItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(backTapped))
// naviBar.items = [naviItem]
//
// view.addSubview(naviBar)
// }




@@ -144,7 +192,7 @@ extension GuideFirstViewController {
}

guideLabel.snp.makeConstraints{ make in
make.top.equalToSuperview().offset(156)
make.top.equalToSuperview().offset(48)
make.leading.equalTo(self.view.safeAreaLayoutGuide).offset(37)
}

55 changes: 35 additions & 20 deletions KorailTalk/KorailTalk/Guide/GuideFourthViewController.swift
Original file line number Diff line number Diff line change
@@ -68,14 +68,14 @@ class GuideFourthViewController: UIViewController {
return label
}()

private let rightButton : UIButton = {
lazy var rightButton : UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "button_right"), for: .normal)
button.addTarget(self, action: #selector(touchupNextButton), for: .touchUpInside)
return button
}()

private let leftButton : UIButton = {
lazy var leftButton : UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "button_left"), for: .normal)
button.addTarget(self, action: #selector(touchupBackButton), for: .touchUpInside)
@@ -88,36 +88,51 @@ class GuideFourthViewController: UIViewController {
layout()
self.setNavigationBar()
}


private func setNavigationBar() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 36))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 18))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 199, height: 29))


topTitle.numberOfLines = 1
topTitle.textAlignment = .center
topTitle.font = .systemFont(ofSize: 15)
topTitle.font = .systemFont(ofSize: 24, weight: .semibold)
topTitle.textColor = .white
topTitle.text = "내일로 두번째 이야기"

let backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: nil)
backBarButtonItem.tintColor = .red

self.navigationItem.backBarButtonItem = backBarButtonItem


let backBarButtonItem = UIBarButtonItem(
// image: UIImage(named:"button_back"),
title: "",
style: .plain,
target: self,
action: #selector(backTapped))
backBarButtonItem.tintColor = .white
self.navigationItem.backBarButtonItem = backBarButtonItem


containerView.addSubview(topTitle)

self.navigationItem.titleView = containerView
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.barTintColor = .systemCyan

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance

self.navigationController?.navigationBar.isTranslucent = false



}
@objc func backTapped(sender: UIBarButtonItem) {
navigationController?.popViewController(animated: false)
}

// private func setNavigationBar() {
// navigationController?.navigationBar.barTintColor = 0x0B4199.color
// navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
// navigationController?.navigationBar.shadowImage = UIImage()
//
// }

private func pushToFifthVC() {
let fifthVC = GuideFifthViewController()
self.navigationController?.pushViewController(fifthVC, animated: false)
@@ -143,7 +158,7 @@ extension GuideFourthViewController {
}

guideLabel.snp.makeConstraints{ make in
make.top.equalToSuperview().offset(156)
make.top.equalToSuperview().offset(48)
make.leading.equalTo(self.view.safeAreaLayoutGuide).offset(37)
}
titleLabel.snp.makeConstraints{ make in
46 changes: 34 additions & 12 deletions KorailTalk/KorailTalk/Guide/GuideSecondViewController.swift
Original file line number Diff line number Diff line change
@@ -102,14 +102,14 @@ class GuideSecondViewController: UIViewController {
return label
}()

private let rightButton : UIButton = {
lazy var rightButton : UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "button_right"), for: .normal)
button.addTarget(self, action: #selector(touchupNextButton), for: .touchUpInside)
return button
}()

private let leftButton : UIButton = {
lazy var leftButton : UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "button_left"), for: .normal)
button.addTarget(self, action: #selector(touchupBackButton), for: .touchUpInside)
@@ -122,28 +122,50 @@ class GuideSecondViewController: UIViewController {
layout()
self.setNavigationBar()
}


private func setNavigationBar() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 36))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 18))
let topTitle = UILabel(frame: CGRect(x: 0, y: 0, width: 199, height: 29))


topTitle.numberOfLines = 1
topTitle.textAlignment = .center
topTitle.font = .systemFont(ofSize: 15)
topTitle.font = .systemFont(ofSize: 24, weight: .semibold)
topTitle.textColor = .white
topTitle.text = "내일로 두번째 이야기"

let backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: nil)
backBarButtonItem.tintColor = .red

let backBarButtonItem = UIBarButtonItem(
// image: UIImage(named:"button_back"),
title: "",
style: .plain,
target: self,
action: #selector(backTapped))
backBarButtonItem.tintColor = .white
self.navigationItem.backBarButtonItem = backBarButtonItem



containerView.addSubview(topTitle)

self.navigationItem.titleView = containerView
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.barTintColor = .systemCyan

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = 0x0B4199.color
self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance

self.navigationController?.navigationBar.isTranslucent = false



}
@objc func backTapped(sender: UIBarButtonItem) {
navigationController?.popViewController(animated: false)
}


private func pushToThirdVC() {
let thirdVC = GuideThirdViewController()
@@ -171,7 +193,7 @@ extension GuideSecondViewController {
}

guideLabel.snp.makeConstraints{ make in
make.top.equalToSuperview().offset(156)
make.top.equalToSuperview().offset(48)
make.leading.equalTo(self.view.safeAreaLayoutGuide).offset(37)
}

Loading