Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
biuer committed Dec 26, 2018
0 parents commit 3576c78
Show file tree
Hide file tree
Showing 29 changed files with 2,087 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
78 changes: 78 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
12 changes: 12 additions & 0 deletions FreeNavigationItem.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Pod::Spec.new do |s|
s.name = "FreeNavigationItem"
s.version = "0.0.1"
s.summary = "Set free UIBarButtonItems"
s.homepage = "https://github.com/Natai/FreeNavigationItem"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "natai" => "" }
s.platform = :ios, "11.0"
s.swift_version = "4.2"
s.source = { :git => "https://github.com/Natai/FreeNavigationItem.git", :tag => "#{s.version}" }
s.source_files = "Source/*.swift"
end
545 changes: 545 additions & 0 deletions FreeNavigationItem.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>
67 changes: 67 additions & 0 deletions FreeNavigationItemDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Created by natai on 2018/12/24.
// Copyright © 2018年 natai. All rights reserved.
//

import UIKit
import FreeNavigationItem

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

override init() {
super.init()
UINavigationBar.freeNavigationItems()
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UINavigationBar.backImageMargin = 0
UINavigationBar.backButtonWidth = 30
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: UINavigationBar.backImageMargin - UINavigationBar.systemBackImageMargin(barMetric: .default), vertical: 0), for: .default)
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: UINavigationBar.backImageMargin - UINavigationBar.systemBackImageMargin(barMetric: .compact), vertical: 0), for: .compact)

// UINavigationBar.defaultMetricBackImageMargin = 0
// UINavigationBar.compactMetricBackImageMargin = 20
// UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: UINavigationBar.defaultMetricBackImageMargin - UINavigationBar.systemBackImageMargin(barMetric: .default), vertical: 0), for: .default)
// UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: UINavigationBar.compactMetricBackImageMargin - UINavigationBar.systemBackImageMargin(barMetric: .compact), vertical: 0), for: .compact)

UINavigationBar.appearance().backIndicatorImage = #imageLiteral(resourceName: "arrow_left")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = #imageLiteral(resourceName: "arrow_left")

UINavigationItem.leftItemsMargin = 0
UINavigationItem.leftItemsSpacing = 0
UINavigationItem.minTitleContentViewMargin = 0
UINavigationItem.rightItemsMargin = 0
UINavigationItem.rightItemsSpacing = 0
UINavigationItem.firstLeftItemToBackSpacing = 0

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:.
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"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"
}
}
6 changes: 6 additions & 0 deletions FreeNavigationItemDemo/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "arrow_left@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "arrow_left@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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.
41 changes: 41 additions & 0 deletions FreeNavigationItemDemo/FirstViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Created by natai on 2018/12/24.
// Copyright © 2018年 natai. All rights reserved.
//

import UIKit
import FreeNavigationItem

class FirstViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

navigationItem.leftItemsMargin = 10
navigationItem.leftItemsSpacing = 2
navigationItem.minTitleContentViewMargin = 4
navigationItem.rightItemsMargin = 5
navigationItem.rightItemsSpacing = 3
navigationItem.firstLeftItemToBackSpacing = 1

let orangeView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 30))
orangeView.backgroundColor = UIColor.orange
navigationItem.titleView = orangeView

let view = UIView(frame: CGRect(x: 0, y: 0, width: 18, height: 30))
view.backgroundColor = UIColor.red
let view2 = UIView(frame: CGRect(x: 0, y: 0, width: 18, height: 30))
view2.backgroundColor = UIColor.cyan
let view3 = UIView(frame: CGRect(x: 0, y: 0, width: 18, height: 30))
view3.backgroundColor = UIColor.red
let view4 = UIView(frame: CGRect(x: 0, y: 0, width: 18, height: 30))
view4.backgroundColor = UIColor.cyan
navigationItem.leftBarButtonItems = [UIBarButtonItem(customView: view), UIBarButtonItem(customView: view2)]
navigationItem.rightBarButtonItems = [UIBarButtonItem(customView: view3), UIBarButtonItem(customView: view4)]
}

override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
navigationItem.titleView?.frame.size.width = UIScreen.main.bounds.width
}
}
45 changes: 45 additions & 0 deletions FreeNavigationItemDemo/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Loading

0 comments on commit 3576c78

Please sign in to comment.