Skip to content

Commit

Permalink
fix: navigation bar 재설정
Browse files Browse the repository at this point in the history
  • Loading branch information
k2645 committed Nov 19, 2024
1 parent d78817a commit ee6f6c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class CustomAlbumViewController: UIViewController {
PHPhotoLibrary.shared().unregisterChangeObserver(self)
}

// MARK: - ViewDidLoad
// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,22 @@ final class EditPhotoViewController: UIViewController {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}

// MARK: - ViewDidLoad
// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()

setup()
configureNavagationBar()
configureAddSubView()
configureConstraints()
configureButtonAction()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

configureNavagationBar()
}

// MARK: - Setup
private func setup() {
view.backgroundColor = .black
Expand Down Expand Up @@ -116,19 +121,32 @@ final class EditPhotoViewController: UIViewController {
navigationItem.title = "사진 편집"

// Left Bar BarButton
let leftBarButton = UIBarButtonItem(title: "닫기")
let closeAction = UIAction { [weak self] _ in
guard let self else { return }
self.navigationController?.popViewController(animated: true)
}
let leftBarButton = UIBarButtonItem(title: "닫기", primaryAction: closeAction)
leftBarButton.setTitleTextAttributes([
NSAttributedString.Key.font: UIFont.ownglyphBerry(size: 17),
NSAttributedString.Key.foregroundColor: UIColor.white
], for: .normal)
leftBarButton.setTitleTextAttributes([
NSAttributedString.Key.font: UIFont.ownglyphBerry(size: 17)
], for: .selected)
navigationItem.leftBarButtonItem = leftBarButton

// Right Bar Button
let rightBarButton = UIBarButtonItem(title: "완료")
let completeAction = UIAction { _ in
// TODO: 다음 화면으로 전환 및 cropImage 호출
}
let rightBarButton = UIBarButtonItem(title: "완료", primaryAction: completeAction)
rightBarButton.setTitleTextAttributes([
NSAttributedString.Key.font: UIFont.ownglyphBerry(size: 17),
NSAttributedString.Key.foregroundColor: UIColor.white
], for: .normal)
rightBarButton.setTitleTextAttributes([
NSAttributedString.Key.font: UIFont.ownglyphBerry(size: 17)
], for: .selected)
navigationItem.rightBarButtonItem = rightBarButton
}

Expand Down Expand Up @@ -216,13 +234,6 @@ final class EditPhotoViewController: UIViewController {

// MARK: - Add Button Action
private func configureButtonAction() {
let closeAction = UIAction { [weak self] _ in
guard let self else { return }
self.navigationController?.popViewController(animated: true)
}
let completeAction = UIAction { [weak self] _ in
// TODO: 다음 화면으로 전환 및 cropImage 호출
}
let rotateButtonAction = UIAction { [weak self] _ in
guard let self else { return }
let image = self.photoImageView.image
Expand All @@ -231,8 +242,6 @@ final class EditPhotoViewController: UIViewController {
let drawButtonAction = UIAction { _ in
// TODO: - Draw Action
}
navigationItem.leftBarButtonItem?.primaryAction = closeAction
navigationItem.rightBarButtonItem?.primaryAction = completeAction
rotateButton.addAction(rotateButtonAction, for: .touchUpInside)
drawButton.addAction(drawButtonAction, for: .touchUpInside)
}
Expand Down

0 comments on commit ee6f6c2

Please sign in to comment.