Repository: tungfam/ImageInNavigationBarDemo
Branch: master
Commit: ded9ae73c812
Files: 14
Total size: 34.2 KB
Directory structure:
gitextract_svexc16_/
├── ImageInNavigationBarDemo/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── image_name.imageset/
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── DemoTableViewController.swift
│ └── Info.plist
├── ImageInNavigationBarDemo.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata/
│ │ └── IDEWorkspaceChecks.plist
│ └── xcuserdata/
│ └── Tung.xcuserdatad/
│ ├── xcdebugger/
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes/
│ └── xcschememanagement.plist
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: ImageInNavigationBarDemo/AppDelegate.swift
================================================
//
// AppDelegate.swift
// ImageInNavigationBarDemo
//
// Created by Tung Fam on 11/14/17.
// Copyright © 2017 Tung Fam. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: ImageInNavigationBarDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: ImageInNavigationBarDemo/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: ImageInNavigationBarDemo/Assets.xcassets/image_name.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ca_image.jpg",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: ImageInNavigationBarDemo/Base.lproj/LaunchScreen.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
================================================
FILE: ImageInNavigationBarDemo/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="KTF-E6-lAe">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Demo Table View Controller-->
<scene sceneID="kjM-cF-uwk">
<objects>
<tableViewController id="56k-Nd-y5r" customClass="DemoTableViewController" customModule="ImageInNavigationBarDemo" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="Mnb-iU-5Wb">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="DemoCell" id="SCT-0z-1Vf">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="SCT-0z-1Vf" id="mxj-08-mdu">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="56k-Nd-y5r" id="lxW-pU-Iqc"/>
<outlet property="delegate" destination="56k-Nd-y5r" id="jOl-N1-6Ls"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="Ykc-Kr-uNU"/>
<connections>
<segue destination="txG-pg-8R0" kind="show" identifier="SegueID" id="j4P-eB-5OA"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="oU7-T1-hfh" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="503.19999999999999" y="116.49175412293854"/>
</scene>
<!--No Image here-->
<scene sceneID="EgN-kL-7G0">
<objects>
<viewController id="txG-pg-8R0" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="io2-qy-tQC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="OxS-OU-GVT"/>
</view>
<navigationItem key="navigationItem" title="No Image here" id="802-Sn-nOL"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="1dI-Ub-MA6" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1273" y="116"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="KTf-A6-3Bd">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="KTF-E6-lAe" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="NH0-4d-KrJ">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="56k-Nd-y5r" kind="relationship" relationship="rootViewController" id="gj1-dA-HJW"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5HQ-N7-LAs" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-220" y="116"/>
</scene>
</scenes>
</document>
================================================
FILE: ImageInNavigationBarDemo/DemoTableViewController.swift
================================================
//
// DemoTableViewController.swift
// ImageInNavigationBarDemo
//
// Created by Tung Fam on 11/14/17.
// Copyright © 2017 Tung Fam. All rights reserved.
//
import UIKit
extension DemoTableViewController {
/// WARNING: Change these constants according to your project's design
private struct Const {
/// Image height/width for Large NavBar state
static let ImageSizeForLargeState: CGFloat = 40
/// Margin from right anchor of safe area to right anchor of Image
static let ImageRightMargin: CGFloat = 16
/// Margin from bottom anchor of NavBar to bottom anchor of Image for Large NavBar state
static let ImageBottomMarginForLargeState: CGFloat = 12
/// Margin from bottom anchor of NavBar to bottom anchor of Image for Small NavBar state
static let ImageBottomMarginForSmallState: CGFloat = 6
/// Image height/width for Small NavBar state
static let ImageSizeForSmallState: CGFloat = 32
/// Height of NavBar for Small state. Usually it's just 44
static let NavBarHeightSmallState: CGFloat = 44
/// Height of NavBar for Large state. Usually it's just 96.5 but if you have a custom font for the title, please make sure to edit this value since it changes the height for Large state of NavBar
static let NavBarHeightLargeState: CGFloat = 96.5
/// Image height/width for Landscape state
static let ScaleForImageSizeForLandscape: CGFloat = 0.65
}
}
final class DemoTableViewController: UITableViewController {
private let imageView = UIImageView(image: UIImage(named: "image_name"))
private var shouldResize: Bool?
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
showTutorialAlert()
observeAndHandleOrientationMode()
if UIDevice.current.orientation.isPortrait {
shouldResize = true
} else if UIDevice.current.orientation.isLandscape {
shouldResize = false
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
showImage(false)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
showImage(true)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
guard let shouldResize = shouldResize
else { assertionFailure("shouldResize wasn't set. reason could be non-handled device orientation state"); return }
if shouldResize {
moveAndResizeImageForPortrait()
}
}
// MARK: - Scroll View Delegates
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard let shouldResize = shouldResize
else { assertionFailure("shouldResize wasn't set. reason could be non-handled device orientation state"); return }
if shouldResize {
moveAndResizeImageForPortrait()
}
}
// MARK: - Private methods
private func setupUI() {
navigationController?.navigationBar.prefersLargeTitles = true
title = "Resizing image 👉"
// Initial setup for image for Large NavBar state since the the screen always has Large NavBar once it gets opened
guard let navigationBar = self.navigationController?.navigationBar else { return }
navigationBar.addSubview(imageView)
imageView.layer.cornerRadius = Const.ImageSizeForLargeState / 2
imageView.clipsToBounds = true
imageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
imageView.rightAnchor.constraint(equalTo: navigationBar.rightAnchor,
constant: -Const.ImageRightMargin),
imageView.bottomAnchor.constraint(equalTo: navigationBar.bottomAnchor,
constant: -Const.ImageBottomMarginForLargeState),
imageView.heightAnchor.constraint(equalToConstant: Const.ImageSizeForLargeState),
imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor)
])
}
private func observeAndHandleOrientationMode() {
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIDeviceOrientationDidChange, object: nil, queue: OperationQueue.current) { [weak self] _ in
if UIDevice.current.orientation.isPortrait {
self?.title = "Resizing image 👉"
self?.moveAndResizeImageForPortrait()
self?.shouldResize = true
} else if UIDevice.current.orientation.isLandscape {
self?.title = "Non 🙅🏽♂️ resizing image"
self?.resizeImageForLandscape()
self?.shouldResize = false
}
}
}
private func moveAndResizeImageForPortrait() {
guard let height = navigationController?.navigationBar.frame.height else { return }
let coeff: CGFloat = {
let delta = height - Const.NavBarHeightSmallState
let heightDifferenceBetweenStates = (Const.NavBarHeightLargeState - Const.NavBarHeightSmallState)
return delta / heightDifferenceBetweenStates
}()
let factor = Const.ImageSizeForSmallState / Const.ImageSizeForLargeState
let scale: CGFloat = {
let sizeAddendumFactor = coeff * (1.0 - factor)
return min(1.0, sizeAddendumFactor + factor)
}()
// Value of difference between icons for large and small states
let sizeDiff = Const.ImageSizeForLargeState * (1.0 - factor) // 8.0
let yTranslation: CGFloat = {
/// This value = 14. It equals to difference of 12 and 6 (bottom margin for large and small states). Also it adds 8.0 (size difference when the image gets smaller size)
let maxYTranslation = Const.ImageBottomMarginForLargeState - Const.ImageBottomMarginForSmallState + sizeDiff
return max(0, min(maxYTranslation, (maxYTranslation - coeff * (Const.ImageBottomMarginForSmallState + sizeDiff))))
}()
let xTranslation = max(0, sizeDiff - coeff * sizeDiff)
imageView.transform = CGAffineTransform.identity
.scaledBy(x: scale, y: scale)
.translatedBy(x: xTranslation, y: yTranslation)
}
private func resizeImageForLandscape() {
let yTranslation = Const.ImageSizeForLargeState * Const.ScaleForImageSizeForLandscape
imageView.transform = CGAffineTransform.identity
.scaledBy(x: Const.ScaleForImageSizeForLandscape, y: Const.ScaleForImageSizeForLandscape)
.translatedBy(x: 0, y: yTranslation)
}
/// Show or hide the image from NavBar while going to next screen or back to initial screen
///
/// - Parameter show: show or hide the image from NavBar
private func showImage(_ show: Bool) {
UIView.animate(withDuration: 0.2) {
self.imageView.alpha = show ? 1.0 : 0.0
}
}
private func showTutorialAlert() {
let alert = UIAlertController(title: "Tutorial", message: "Scroll down and up to resize the image in navigation bar.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Got it!", style: .default)
alert.addAction(okAction)
present(alert, animated: true)
}
}
extension DemoTableViewController {
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 3
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DemoCell", for: indexPath)
cell.textLabel?.text = "row \(indexPath.row)"
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "SegueID", sender: nil)
}
}
================================================
FILE: ImageInNavigationBarDemo/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
================================================
FILE: ImageInNavigationBarDemo.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
A64022B81FBB249000E78BF9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A64022B71FBB249000E78BF9 /* AppDelegate.swift */; };
A64022BD1FBB249000E78BF9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A64022BB1FBB249000E78BF9 /* Main.storyboard */; };
A64022BF1FBB249000E78BF9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A64022BE1FBB249000E78BF9 /* Assets.xcassets */; };
A64022C21FBB249000E78BF9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A64022C01FBB249000E78BF9 /* LaunchScreen.storyboard */; };
A64022CA1FBB24AA00E78BF9 /* DemoTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A64022C91FBB24AA00E78BF9 /* DemoTableViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
A64022B41FBB249000E78BF9 /* ImageInNavigationBarDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageInNavigationBarDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
A64022B71FBB249000E78BF9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A64022BC1FBB249000E78BF9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A64022BE1FBB249000E78BF9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A64022C11FBB249000E78BF9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
A64022C31FBB249000E78BF9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A64022C91FBB24AA00E78BF9 /* DemoTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoTableViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
A64022B11FBB249000E78BF9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
A64022AB1FBB249000E78BF9 = {
isa = PBXGroup;
children = (
A64022B61FBB249000E78BF9 /* ImageInNavigationBarDemo */,
A64022B51FBB249000E78BF9 /* Products */,
);
sourceTree = "<group>";
};
A64022B51FBB249000E78BF9 /* Products */ = {
isa = PBXGroup;
children = (
A64022B41FBB249000E78BF9 /* ImageInNavigationBarDemo.app */,
);
name = Products;
sourceTree = "<group>";
};
A64022B61FBB249000E78BF9 /* ImageInNavigationBarDemo */ = {
isa = PBXGroup;
children = (
A64022B71FBB249000E78BF9 /* AppDelegate.swift */,
A64022C91FBB24AA00E78BF9 /* DemoTableViewController.swift */,
A64022BB1FBB249000E78BF9 /* Main.storyboard */,
A64022BE1FBB249000E78BF9 /* Assets.xcassets */,
A64022C01FBB249000E78BF9 /* LaunchScreen.storyboard */,
A64022C31FBB249000E78BF9 /* Info.plist */,
);
path = ImageInNavigationBarDemo;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
A64022B31FBB249000E78BF9 /* ImageInNavigationBarDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = A64022C61FBB249000E78BF9 /* Build configuration list for PBXNativeTarget "ImageInNavigationBarDemo" */;
buildPhases = (
A64022B01FBB249000E78BF9 /* Sources */,
A64022B11FBB249000E78BF9 /* Frameworks */,
A64022B21FBB249000E78BF9 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = ImageInNavigationBarDemo;
productName = ImageInNavigationBarDemo;
productReference = A64022B41FBB249000E78BF9 /* ImageInNavigationBarDemo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
A64022AC1FBB249000E78BF9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0910;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = "Tung Fam";
TargetAttributes = {
A64022B31FBB249000E78BF9 = {
CreatedOnToolsVersion = 9.1;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = A64022AF1FBB249000E78BF9 /* Build configuration list for PBXProject "ImageInNavigationBarDemo" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = A64022AB1FBB249000E78BF9;
productRefGroup = A64022B51FBB249000E78BF9 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
A64022B31FBB249000E78BF9 /* ImageInNavigationBarDemo */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
A64022B21FBB249000E78BF9 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A64022C21FBB249000E78BF9 /* LaunchScreen.storyboard in Resources */,
A64022BF1FBB249000E78BF9 /* Assets.xcassets in Resources */,
A64022BD1FBB249000E78BF9 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
A64022B01FBB249000E78BF9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A64022B81FBB249000E78BF9 /* AppDelegate.swift in Sources */,
A64022CA1FBB24AA00E78BF9 /* DemoTableViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
A64022BB1FBB249000E78BF9 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
A64022BC1FBB249000E78BF9 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
A64022C01FBB249000E78BF9 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
A64022C11FBB249000E78BF9 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
A64022C41FBB249000E78BF9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
A64022C51FBB249000E78BF9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
A64022C71FBB249000E78BF9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = YZT3W6BM9X;
INFOPLIST_FILE = ImageInNavigationBarDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mintung.ImageInNavigationBarDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
A64022C81FBB249000E78BF9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = YZT3W6BM9X;
INFOPLIST_FILE = ImageInNavigationBarDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mintung.ImageInNavigationBarDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
A64022AF1FBB249000E78BF9 /* Build configuration list for PBXProject "ImageInNavigationBarDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A64022C41FBB249000E78BF9 /* Debug */,
A64022C51FBB249000E78BF9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A64022C61FBB249000E78BF9 /* Build configuration list for PBXNativeTarget "ImageInNavigationBarDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A64022C71FBB249000E78BF9 /* Debug */,
A64022C81FBB249000E78BF9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = A64022AC1FBB249000E78BF9 /* Project object */;
}
================================================
FILE: ImageInNavigationBarDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ImageInNavigationBarDemo.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: ImageInNavigationBarDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
================================================
FILE: ImageInNavigationBarDemo.xcodeproj/xcuserdata/Tung.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
================================================
FILE: ImageInNavigationBarDemo.xcodeproj/xcuserdata/Tung.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ImageInNavigationBarDemo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
================================================
FILE: README.md
================================================
# Demo project to build resizing image in Navigation Bar with Large Title (iOS 11+)
Demo project that shows the implementation of an image which resizes according to the height of navigation bar with a large title (iOS 11+).
## Tutorial
Follow this detailed [tutorial](https://blog.uptech.team/how-to-build-resizing-image-in-navigation-bar-with-large-title-8ba2e8bcb840) to build it in your project.
## Demo
<img src="Demo/demo.gif" width="750">
gitextract_svexc16_/ ├── ImageInNavigationBarDemo/ │ ├── AppDelegate.swift │ ├── Assets.xcassets/ │ │ ├── AppIcon.appiconset/ │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── image_name.imageset/ │ │ └── Contents.json │ ├── Base.lproj/ │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── DemoTableViewController.swift │ └── Info.plist ├── ImageInNavigationBarDemo.xcodeproj/ │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata/ │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata/ │ └── Tung.xcuserdatad/ │ ├── xcdebugger/ │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes/ │ └── xcschememanagement.plist └── README.md
Condensed preview — 14 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (39K chars).
[
{
"path": "ImageInNavigationBarDemo/AppDelegate.swift",
"chars": 2182,
"preview": "//\n// AppDelegate.swift\n// ImageInNavigationBarDemo\n//\n// Created by Tung Fam on 11/14/17.\n// Copyright © 2017 Tung "
},
{
"path": "ImageInNavigationBarDemo/Assets.xcassets/AppIcon.appiconset/Contents.json",
"chars": 1590,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"20x20\",\n \"scale\" : \"2x\"\n },\n {\n \"idiom\""
},
{
"path": "ImageInNavigationBarDemo/Assets.xcassets/Contents.json",
"chars": 62,
"preview": "{\n \"info\" : {\n \"version\" : 1,\n \"author\" : \"xcode\"\n }\n}"
},
{
"path": "ImageInNavigationBarDemo/Assets.xcassets/image_name.imageset/Contents.json",
"chars": 305,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"universal\",\n \"scale\" : \"1x\"\n },\n {\n \"idiom\" : \"universal\",\n "
},
{
"path": "ImageInNavigationBarDemo/Base.lproj/LaunchScreen.storyboard",
"chars": 1681,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "ImageInNavigationBarDemo/Base.lproj/Main.storyboard",
"chars": 5779,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "ImageInNavigationBarDemo/DemoTableViewController.swift",
"chars": 8181,
"preview": "//\n// DemoTableViewController.swift\n// ImageInNavigationBarDemo\n//\n// Created by Tung Fam on 11/14/17.\n// Copyright "
},
{
"path": "ImageInNavigationBarDemo/Info.plist",
"chars": 1523,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "ImageInNavigationBarDemo.xcodeproj/project.pbxproj",
"chars": 12424,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 48;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "ImageInNavigationBarDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 169,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:ImageInNavigati"
},
{
"path": "ImageInNavigationBarDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
"chars": 238,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "ImageInNavigationBarDemo.xcodeproj/xcuserdata/Tung.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist",
"chars": 91,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bucket\n type = \"1\"\n version = \"2.0\">\n</Bucket>\n"
},
{
"path": "ImageInNavigationBarDemo.xcodeproj/xcuserdata/Tung.xcuserdatad/xcschemes/xcschememanagement.plist",
"chars": 347,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "README.md",
"chars": 450,
"preview": "# Demo project to build resizing image in Navigation Bar with Large Title (iOS 11+)\nDemo project that shows the implemen"
}
]
About this extraction
This page contains the full source code of the tungfam/ImageInNavigationBarDemo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 14 files (34.2 KB), approximately 10.2k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.