From ee6f6c2f2f2dfdcbef4a31a225dd78f7d69c061d Mon Sep 17 00:00:00 2001 From: k2645 Date: Wed, 20 Nov 2024 01:14:41 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20navigation=20bar=20=EC=9E=AC=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/CustomAlbumViewController.swift | 2 +- .../EditPhoto/EditPhotoViewController.swift | 35 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift index 2335a640..53eabde4 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift @@ -37,7 +37,7 @@ final class CustomAlbumViewController: UIViewController { PHPhotoLibrary.shared().unregisterChangeObserver(self) } - // MARK: - ViewDidLoad + // MARK: - View Life Cycle override func viewDidLoad() { super.viewDidLoad() diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift index aabd9846..d5d9f40d 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift @@ -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 @@ -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 } @@ -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 @@ -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) }