From 595c71d5d0fcad7ebf8be92eebda1d8deb692790 Mon Sep 17 00:00:00 2001 From: Mijin Jeon Date: Mon, 4 Feb 2019 01:51:11 +0900 Subject: [PATCH] Feat: Add UISegmentedControl to set distance #71 --- .../MartHoliday/Base.lproj/Main.storyboard | 41 ++++++++++++++++++- .../LocationSearchViewController.swift | 32 ++++++++++++--- .../ViewController/MainViewController.swift | 2 +- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/MartHoliday/MartHoliday/Base.lproj/Main.storyboard b/MartHoliday/MartHoliday/Base.lproj/Main.storyboard index 57be9c7..5eab739 100644 --- a/MartHoliday/MartHoliday/Base.lproj/Main.storyboard +++ b/MartHoliday/MartHoliday/Base.lproj/Main.storyboard @@ -475,17 +475,48 @@ Cgo - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -572,5 +603,11 @@ Cgo + + + + + + diff --git a/MartHoliday/MartHoliday/ViewController/LocationSearchViewController.swift b/MartHoliday/MartHoliday/ViewController/LocationSearchViewController.swift index 647687e..a429aff 100644 --- a/MartHoliday/MartHoliday/ViewController/LocationSearchViewController.swift +++ b/MartHoliday/MartHoliday/ViewController/LocationSearchViewController.swift @@ -24,12 +24,13 @@ class LocationSearchViewController: UIViewController, NMapViewDelegate, NMapPOId override func viewDidLoad() { super.viewDidLoad() - locationTrackingStateButton = setLocationTrackingButton() + self.setNavigationBar() + // 위치서비스 허용했는지 검사 추가 / 안했으면 setting으로 넘김 guard let locationManager = NMapLocationManager.getSharedInstance() else { return } self.locationManager = locationManager - mapView = NMapView(frame: self.view.frame) + mapView = NMapView(frame: CGRect(x: 0, y: 45, width: self.view.frame.width, height: self.view.frame.height-45)) if let mapView = mapView { @@ -45,15 +46,20 @@ class LocationSearchViewController: UIViewController, NMapViewDelegate, NMapPOId mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] currentState = .tracking + locationTrackingStateButton = setLocationTrackingButton() enableLocationUpdate() view.addSubview(mapView) + if let button = locationTrackingStateButton { + mapView.addSubview(button) + } } - if let button = locationTrackingStateButton { - self.view.addSubview(button) - } + } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + self.setNavigationBar() } override func viewDidAppear(_ animated: Bool) { @@ -67,12 +73,26 @@ class LocationSearchViewController: UIViewController, NMapViewDelegate, NMapPOId disableLocationUpdate() } + private func setNavigationBar() { + navigationController?.navigationBar.barTintColor = UIColor.appColor(color: .mint) + navigationController?.navigationBar.isTranslucent = false + // To remove 1px line of under the navigationBar + navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) + navigationController?.navigationBar.shadowImage = UIImage() + self.navigationItem.title = "내 주변 마트 검색" + } private func setLocationTrackingButton() -> UIButton { let button = UIButton(type: .custom) button.frame = CGRect(x: 15, y: 80, width: 36, height: 36) - button.setImage(UIImage(named: "v4_btn_navi_location_normal"), for: .normal) + + switch currentState { + case .disabled: + locationTrackingStateButton?.setImage(UIImage(named: "v4_btn_navi_location_normal"), for: .normal) + case .tracking: + locationTrackingStateButton?.setImage(UIImage(named: "v4_btn_navi_location_selected"), for: .normal) + } button.addTarget(self, action: #selector(locationTrackingButtonTapped(_:)), for: .touchUpInside) diff --git a/MartHoliday/MartHoliday/ViewController/MainViewController.swift b/MartHoliday/MartHoliday/ViewController/MainViewController.swift index 60c4bbe..198f723 100644 --- a/MartHoliday/MartHoliday/ViewController/MainViewController.swift +++ b/MartHoliday/MartHoliday/ViewController/MainViewController.swift @@ -313,7 +313,7 @@ extension MainViewController: MFMailComposeViewControllerDelegate { self.navigationController?.pushViewController(nextVC, animated: true) case .location: handleDismiss() - let nextVC = LocationSearchViewController() + guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "locationVC") as? LocationSearchViewController else { return } self.navigationController?.pushViewController(nextVC, animated: true) case .sendMail: handleDismiss()