Skip to content

Commit

Permalink
Update navigation bar appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
dypme committed Jun 24, 2022
1 parent 883b284 commit 6fc9592
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 29 deletions.
17 changes: 2 additions & 15 deletions iOStarter/Controller/Base/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

if let backBtn = self.navigationItem.leftBarButtonItem {
if backBtn.tag == 0 {
backBtn.target = self
backBtn.action = #selector(popBackNavigation(_:))
}
}

setupMethod()
setupView()

fetch()
}

Expand All @@ -40,16 +32,11 @@ class ViewController: UIViewController {
}

func setupView() {
let backBarButton = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
navigationItem.backBarButtonItem = backBarButton
}

@objc func fetch() {

}

/// Function back to presenting viewcontroller
///
/// - Parameter barButtonItem: Sender of button bar item
@objc private func popBackNavigation(_ barButtonItem: UIBarButtonItem) {
_ = self.navigationController?.popViewController(animated: true)
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"images" : [
{
"filename" : "outline_arrow_back_black_20pt_1x.png",
"idiom" : "universal",
"filename" : "ic-back.png",
"scale" : "1x"
},
{
"filename" : "outline_arrow_back_black_20pt_2x.png",
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"filename" : "outline_arrow_back_black_20pt_3x.png",
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 6 additions & 8 deletions iOStarter/Storyboard/Menu.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ssq-FX-45Z">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ssq-FX-45Z">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="collection view cell content view" minToolsVersion="11.0"/>
Expand All @@ -13,7 +13,7 @@
<!--Table-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController storyboardIdentifier="TableVC" id="Y6W-OH-hqX" customClass="TableVC" customModule="Test8" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="TableVC" id="Y6W-OH-hqX" customClass="TableVC" customModule="iOStarter" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -63,7 +63,7 @@
<!--Collection-->
<scene sceneID="2vO-tB-28E">
<objects>
<viewController storyboardIdentifier="GridVC" id="HRl-Hn-SIe" customClass="GridVC" customModule="Test8" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="GridVC" id="HRl-Hn-SIe" customClass="GridVC" customModule="iOStarter" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ikx-Cu-Jv6">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -78,7 +78,7 @@
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="Jw6-WG-bgw" customClass="ItemCell" customModule="Test8" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="Jw6-WG-bgw" customClass="ItemCell" customModule="iOStarter" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="124" height="168.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="PDD-1h-kzx">
Expand Down Expand Up @@ -149,7 +149,7 @@
<!--title.example-->
<scene sceneID="wyM-iH-KFI">
<objects>
<viewController storyboardIdentifier="ExampleVC" id="ssq-FX-45Z" customClass="ExampleVC" customModule="Test8" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="ExampleVC" id="ssq-FX-45Z" customClass="ExampleVC" customModule="iOStarter" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="1Bt-9R-m2W">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -188,7 +188,6 @@
</constraints>
</view>
<navigationItem key="navigationItem" title="title.example" id="mud-44-es4">
<barButtonItem key="leftBarButtonItem" image="ic-back" id="sCK-5a-kqO"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="l10nTitle" value="title.example"/>
</userDefinedRuntimeAttributes>
Expand Down Expand Up @@ -302,7 +301,6 @@
</scene>
</scenes>
<resources>
<image name="ic-back" width="14" height="24"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
Expand Down
34 changes: 34 additions & 0 deletions iOStarter/Supporting Files/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,44 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

NVActivityIndicatorView.DEFAULT_TYPE = .ballPulse

configureNavigationBar()

// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5) {
// fatalError("Test crashlytics")
// }
}

func configureNavigationBar() {
let navigationBarAppearance = UINavigationBar.appearance()
navigationBarAppearance.shadowImage = UIImage()
navigationBarAppearance.barTintColor = UIColor.white
navigationBarAppearance.backgroundColor = UIColor.white
let attrTitle = [
NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16),
NSAttributedString.Key.foregroundColor: Colors.primaryBlack.color
]
navigationBarAppearance.titleTextAttributes = attrTitle
navigationBarAppearance.tintColor = Colors.primaryBlack.color
navigationBarAppearance.setBackgroundImage(UIImage(), for: .default)
navigationBarAppearance.backIndicatorImage = Asset.icBack.image
navigationBarAppearance.backIndicatorTransitionMaskImage = Asset.icBack.image

if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = navigationBarAppearance.backgroundColor
appearance.titleTextAttributes = attrTitle
appearance.shadowColor = .clear
appearance.shadowImage = navigationBarAppearance.shadowImage
appearance.setBackIndicatorImage(
navigationBarAppearance.backIndicatorImage,
transitionMaskImage: navigationBarAppearance.backIndicatorTransitionMaskImage
)

UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
}

/// Configure root view controller when applicatio open
func setupView() {
window?.backgroundColor = UIColor.white
Expand All @@ -87,6 +120,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

completionHandler(.newData)
}

func applicationWillResignActive(_ application: UIApplication) {
Expand Down

0 comments on commit 6fc9592

Please sign in to comment.