Repository: devxoul/UINavigationItem-Margin
Branch: master
Commit: 701e0ea3aee1
Files: 26
Total size: 72.1 KB
Directory structure:
gitextract_mraiw755/
├── .gitignore
├── .travis.yml
├── Example/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ └── AppIcon.appiconset/
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
├── LICENSE
├── README.md
├── UINavigationItem+Margin/
│ ├── Info.plist
│ ├── Swizzle.h
│ ├── Swizzle.m
│ ├── UINavigation+Margin.modulemap
│ ├── UINavigationBarContentView+Margin.h
│ ├── UINavigationBarContentView+Margin.m
│ ├── UINavigationBarContentViewLayout+Margin.h
│ ├── UINavigationBarContentViewLayout+Margin.m
│ ├── UINavigationItem+Margin.h
│ └── UINavigationItem+Margin.m
├── UINavigationItem+Margin.podspec
├── UINavigationItem+Margin.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ └── xcshareddata/
│ └── xcschemes/
│ └── UINavigationItem+Margin.xcscheme
└── UINavigationItem+MarginTests/
├── Info.plist
└── UINavigationItem_MarginTests.m
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
================================================
FILE: .travis.yml
================================================
language: objective-c
osx_image: xcode9
sudo: false
env:
global:
- PROJECT="UINavigationItem+Margin.xcodeproj"
- SCHEME="UINavigationItem+Margin"
- SDK="iphonesimulator11.0"
- ACTION="test"
matrix:
- IOS_DESTINATION="platform=iOS Simulator,name=iPhone 5S,OS=10.3.1"
- IOS_DESTINATION="platform=iOS Simulator,name=iPhone 6S,OS=10.3.1"
- IOS_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=10.3.1"
- IOS_DESTINATION="platform=iOS Simulator,name=iPhone 5S,OS=11.0"
- IOS_DESTINATION="platform=iOS Simulator,name=iPhone 6S,OS=11.0"
- IOS_DESTINATION="platform=iOS Simulator,name=iPhone 7 Plus,OS=11.0"
script:
- set -o pipefail && xcodebuild clean $ACTION -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$IOS_DESTINATION" -configuration Debug CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c
================================================
FILE: Example/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Example
//
// Created by Suyeol Jeon on 02/04/2017.
// Copyright © 2017 Suyeol Jeon. 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: Example/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"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"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example/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="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<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">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<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"/>
</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: Example/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="7Sf-4P-0Oe">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<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"/>
</view>
<navigationItem key="navigationItem" id="szs-qa-UrL">
<barButtonItem key="leftBarButtonItem" systemItem="edit" id="C2Q-iF-ddS"/>
<barButtonItem key="rightBarButtonItem" systemItem="done" id="2FT-dP-01c"/>
</navigationItem>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1537" y="-546"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="BTd-xo-xrw">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="7Sf-4P-0Oe" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Wz4-GG-Bme">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="6mY-sw-k8r"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="U6J-J3-vD5" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="725.60000000000002" y="-545.57721139430294"/>
</scene>
</scenes>
</document>
================================================
FILE: Example/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>en</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>
</dict>
</plist>
================================================
FILE: Example/ViewController.swift
================================================
//
// ViewController.swift
// Example
//
// Created by Suyeol Jeon on 02/04/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
import UIKit
import UINavigationItem_Margin
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.leftMargin = 0
self.navigationItem.rightMargin = 0
}
}
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 Suyeol Jeon (xoul.kr)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
UINavigationItem+Margin
=======================
[](https://travis-ci.org/devxoul/UINavigationItem-Margin)
[](http://cocoapods.org/?q=name%3AUINavigationItem%2BMargin%20author%3Adevxoul)
Margin for UINavigationItem.
Setting Margins
---------------
Just set `leftMargin` and `rightMargin` of your UINavigationItem.
```objc
navigationItem.leftMargin = 0;
navigationItem.rightMargin = 0;
```

Wow, margin has disappeared.
Even you can do this:
```objc
navigationItem.leftMargin = 50;
navigationItem.rightMargin = 20;
```

Looks ugly but works.
System Margins
--------------
Want to restore margins? Use `[UINavigationItem systemMargin]`.
```objc
navigationItem.leftMargin = [UINavigationItem systemMargin]; // 16 on iOS 7+
navigationItem.rightMargin = [UINavigationItem systemMargin];
```

Installation
------------
I recommend you to use [CocoaPods](http://cocoapods.org).
**Podfile**
```ruby
pod 'UINavigationItem+Margin'
```
License
-------
**UINavigationItem+Margin** is under MIT license. See the LICENSE file for more info.
================================================
FILE: UINavigationItem+Margin/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>en</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>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
================================================
FILE: UINavigationItem+Margin/Swizzle.h
================================================
//
// Swizzle.h
// UINavigationItem+Margin
//
// Created by Suyeol Jeon on 17/10/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
void _navigationitem_margin_swizzle_self(Class class, NSString *oldSelectorName);
void _navigationitem_margin_swizzle(Class oldClass, NSString *oldSelectorName, Class newClass);
void swizzleUINavigationBarContentViewIfNeeded(void);
================================================
FILE: UINavigationItem+Margin/Swizzle.m
================================================
//
// Swizzle.m
// UINavigationItem+Margin
//
// Created by Suyeol Jeon on 17/10/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import "Swizzle.h"
void _navigationitem_margin_swizzle_full(Class oldClass, NSString *oldSelectorName,
Class newClass, NSString *newSelectorName) {
Method old = class_getInstanceMethod(oldClass, NSSelectorFromString(oldSelectorName));
Method new = class_getInstanceMethod(newClass, NSSelectorFromString(newSelectorName));
method_exchangeImplementations(old, new);
}
void _navigationitem_margin_swizzle_self(Class class, NSString *oldSelectorName) {
_navigationitem_margin_swizzle(class, oldSelectorName, class);
}
void _navigationitem_margin_swizzle(Class oldClass, NSString *oldSelectorName, Class newClass) {
NSString *newSelectorName = [NSString stringWithFormat:@"_navigationitem_margin_%@", oldSelectorName];
_navigationitem_margin_swizzle_full(oldClass, oldSelectorName, newClass, newSelectorName);
}
void _swizzleUINavigationBarContentView() {
Class class = NSClassFromString(@"_UINavigationBarContentView");
if (!class) {
return;
}
_navigationitem_margin_swizzle(class, @"layoutSubviews", NSObject.class);
}
void _swizzleUINavigationBarContentViewLayout() {
Class class = NSClassFromString(@"_UINavigationBarContentViewLayout");
if (!class) {
return;
}
_navigationitem_margin_swizzle(class, @"_updateMarginConstraints", NSObject.class);
}
void swizzleUINavigationBarContentViewIfNeeded() {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_swizzleUINavigationBarContentView();
_swizzleUINavigationBarContentViewLayout();
});
}
================================================
FILE: UINavigationItem+Margin/UINavigation+Margin.modulemap
================================================
framework module UINavigationItem_Margin {
umbrella header "UINavigationItem+Margin.h"
export *
module * { export * }
}
================================================
FILE: UINavigationItem+Margin/UINavigationBarContentView+Margin.h
================================================
//
// UINavigationBarContentView+Margin.h
// UINavigationItem+Margin
//
// Created by Suyeol Jeon on 17/10/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NSObject (UINavigationBarContentView_Margin)
@end
================================================
FILE: UINavigationItem+Margin/UINavigationBarContentView+Margin.m
================================================
//
// UINavigationBarContentView+Margin.m
// UINavigationItem+Margin
//
// Created by Suyeol Jeon on 17/10/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
#import "UINavigationBarContentViewLayout+Margin.h"
#import "Swizzle.h"
@implementation NSObject (UINavigationBarContentViewLayout_Margin)
void perform(id object, NSString *selectorName)
{
SEL selector = NSSelectorFromString(selectorName);
IMP imp = [object methodForSelector:selector];
void (*func)(id, SEL) = (void *)imp;
func(object, selector);
}
- (void)_navigationitem_margin_layoutSubviews {
[self _navigationitem_margin_layoutSubviews];
if (![NSStringFromClass(self.class) isEqualToString:@"_UINavigationBarContentView"]) {
return;
}
id layout = [self valueForKey:@"_layout"];
if (!layout) {
return;
}
perform(layout, @"_updateMarginConstraints");
}
@end
================================================
FILE: UINavigationItem+Margin/UINavigationBarContentViewLayout+Margin.h
================================================
//
// UINavigationBarContentViewLayout+Margin.h
// UINavigationItem+Margin
//
// Created by Suyeol Jeon on 17/10/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NSObject (UINavigationBarContentViewLayout_Margin)
@end
================================================
FILE: UINavigationItem+Margin/UINavigationBarContentViewLayout+Margin.m
================================================
//
// UINavigationBarContentViewLayout+Margin.m
// UINavigationItem+Margin
//
// Created by Suyeol Jeon on 17/10/2017.
// Copyright © 2017 Suyeol Jeon. All rights reserved.
//
#import "UINavigationBarContentViewLayout+Margin.h"
#import "Swizzle.h"
@implementation NSObject (UINavigationBarContentViewLayout_Margin)
- (void)_navigationitem_margin__updateMarginConstraints {
[self _navigationitem_margin__updateMarginConstraints];
[self _manipulateLeadingBarConstraints];
[self _manipulateTrailingBarConstraints];
}
- (void)_manipulateLeadingBarConstraints {
NSArray<NSLayoutConstraint *> *leadingBarConstraints = [self valueForKey:@"_leadingBarConstraints"];
if (!leadingBarConstraints) {
return;
}
for (NSLayoutConstraint *constraint in leadingBarConstraints) {
if (constraint.firstAttribute == NSLayoutAttributeLeading) {
constraint.constant = -16;
}
}
}
- (void)_manipulateTrailingBarConstraints {
NSArray<NSLayoutConstraint *> *trailingBarConstraints = [self valueForKey:@"_trailingBarConstraints"];
if (!trailingBarConstraints) {
return;
}
for (NSLayoutConstraint *constraint in trailingBarConstraints) {
if (constraint.firstAttribute == NSLayoutAttributeTrailing) {
constraint.constant = 16;
}
}
}
@end
================================================
FILE: UINavigationItem+Margin/UINavigationItem+Margin.h
================================================
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Suyeol Jeon (xoul.kr)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#import <UIKit/UIKit.h>
#import "UINavigationBarContentViewLayout+Margin.h"
FOUNDATION_EXPORT double UINavigationItem_MarginVersionNumber;
FOUNDATION_EXPORT const unsigned char UINavigationItem_MarginVersionString[];
@interface UINavigationItem (Margin)
@property (nonatomic, assign) CGFloat leftMargin;
@property (nonatomic, assign) CGFloat rightMargin;
+ (CGFloat)systemMargin;
@end
================================================
FILE: UINavigationItem+Margin/UINavigationItem+Margin.m
================================================
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Suyeol Jeon (xoul.kr)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#import <execinfo.h>
#import <objc/runtime.h>
#import "UINavigationItem+Margin.h"
#import "Swizzle.h"
#define isCalledFromSystem (BOOL)^(void) { \
int depth = 3; \
void *callstack[depth]; \
int frames = backtrace(callstack, depth); \
char **symbols = backtrace_symbols(callstack, frames); \
int contains = 0; \
if (strstr(symbols[depth - 1], "UIKit") != NULL) { \
contains = 1; \
} \
free(symbols); \
return contains; \
}()
#define iOS11 (BOOL)^(void){ \
if (@available(iOS 11, *)) { \
return YES; \
} else { \
return NO; \
} \
}()
@implementation UINavigationItem (Margin)
+ (void)load {
// left
_navigationitem_margin_swizzle_self(self, @"leftBarButtonItem");
_navigationitem_margin_swizzle_self(self, @"setLeftBarButtonItem:animated:");
_navigationitem_margin_swizzle_self(self, @"leftBarButtonItems");
_navigationitem_margin_swizzle_self(self, @"setLeftBarButtonItems:animated:");
// right
_navigationitem_margin_swizzle_self(self, @"rightBarButtonItem");
_navigationitem_margin_swizzle_self(self, @"setRightBarButtonItem:animated:");
_navigationitem_margin_swizzle_self(self, @"rightBarButtonItems");
_navigationitem_margin_swizzle_self(self, @"setRightBarButtonItems:animated:");
}
#pragma mark - Global
+ (CGFloat)systemMargin {
return 16; // iOS 7~
}
#pragma mark - Spacer
- (UIBarButtonItem *)spacerForItem:(UIBarButtonItem *)item withMargin:(CGFloat)margin {
UIBarButtonSystemItem type = UIBarButtonSystemItemFixedSpace;
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:type target:self action:nil];
if (iOS11) {
spacer.width = margin + 8;
} else {
spacer.width = margin - [self.class systemMargin];
}
CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
// a margin of private class `UINavigationButton` is different from custom view
if (!iOS11 && !item.customView && screenWidth < 375) { // 3.5 and 4 inch
spacer.width += 8;
} else if (screenWidth >= 414) { // 5.5 inch
spacer.width -= 4;
}
return spacer;
}
- (UIBarButtonItem *)leftSpacerForItem:(UIBarButtonItem *)item {
return [self spacerForItem:item withMargin:self.leftMargin];
}
- (UIBarButtonItem *)rightSpacerForItem:(UIBarButtonItem *)item {
return [self spacerForItem:item withMargin:self.rightMargin];
}
#pragma mark - Margin
- (void)initializeMarginsIfNeeded {
NSNumber *leftMargin = objc_getAssociatedObject(self, @selector(leftMargin));
if (!leftMargin) {
self.leftMargin = [self.class systemMargin];
}
NSNumber *rightMargin = objc_getAssociatedObject(self, @selector(rightMargin));
if (!rightMargin) {
self.rightMargin = [self.class systemMargin];
}
}
- (CGFloat)leftMargin {
[self initializeMarginsIfNeeded];
NSNumber *value = objc_getAssociatedObject(self, @selector(leftMargin));
return value.floatValue;
}
- (void)setLeftMargin:(CGFloat)leftMargin {
swizzleUINavigationBarContentViewIfNeeded();
objc_setAssociatedObject(self, @selector(leftMargin), @(leftMargin), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
self.leftBarButtonItems = self.leftBarButtonItems;
}
- (CGFloat)rightMargin {
[self initializeMarginsIfNeeded];
NSNumber *value = objc_getAssociatedObject(self, @selector(rightMargin));
return value.floatValue;
}
- (void)setRightMargin:(CGFloat)rightMargin {
swizzleUINavigationBarContentViewIfNeeded();
objc_setAssociatedObject(self, @selector(rightMargin), @(rightMargin), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
self.rightBarButtonItems = self.rightBarButtonItems;
}
#pragma mark - Original Bar Button Items
- (NSArray *)originalLeftBarButtonItems {
NSArray *items = objc_getAssociatedObject(self, @selector(originalLeftBarButtonItems));
if (!items) {
items = [self _navigationitem_margin_leftBarButtonItems];
self.originalLeftBarButtonItems = items;
}
return items;
}
- (void)setOriginalLeftBarButtonItems:(NSArray *)items {
objc_setAssociatedObject(self, @selector(originalLeftBarButtonItems), items, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (NSArray *)originalRightBarButtonItems {
NSArray *items = objc_getAssociatedObject(self, @selector(originalRightBarButtonItems));
if (!items) {
items = [self _navigationitem_margin_rightBarButtonItems];
self.originalRightBarButtonItems = items;
}
return items;
}
- (void)setOriginalRightBarButtonItems:(NSArray *)items {
objc_setAssociatedObject(self, @selector(originalRightBarButtonItems), items, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
#pragma mark - Bar Button Item
- (UIBarButtonItem *)_navigationitem_margin_leftBarButtonItem {
if (iOS11 && isCalledFromSystem) {
return [self _navigationitem_margin_leftBarButtonItem];
} else {
return self.originalLeftBarButtonItems.firstObject;
}
}
- (void)_navigationitem_margin_setLeftBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated {
if (!item) {
[self setLeftBarButtonItems:nil animated:animated];
} else {
[self setLeftBarButtonItems:@[item] animated:animated];
}
}
- (UIBarButtonItem *)_navigationitem_margin_rightBarButtonItem {
if (iOS11 && isCalledFromSystem) {
return [self _navigationitem_margin_rightBarButtonItem];
} else {
return self.originalRightBarButtonItems.firstObject;
}
}
- (void)_navigationitem_margin_setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated {
if (!item) {
[self setRightBarButtonItems:nil animated:animated];
} else {
[self setRightBarButtonItems:@[item] animated:animated];
}
}
#pragma mark - Bar Button Items
- (NSArray *)_navigationitem_margin_leftBarButtonItems {
if (iOS11 && isCalledFromSystem) {
return [self _navigationitem_margin_leftBarButtonItems];
} else {
return self.originalLeftBarButtonItems;
}
}
- (void)_navigationitem_margin_setLeftBarButtonItems:(NSArray *)items animated:(BOOL)animated {
if (items.count) {
self.originalLeftBarButtonItems = items;
UIBarButtonItem *spacer = [self leftSpacerForItem:items.firstObject];
NSArray *itemsWithMargin = [@[spacer] arrayByAddingObjectsFromArray:items];
[self _navigationitem_margin_setLeftBarButtonItems:itemsWithMargin animated:animated];
} else {
self.originalLeftBarButtonItems = nil;
[self _navigationitem_margin_setLeftBarButtonItems:nil animated:animated];
}
}
- (NSArray *)_navigationitem_margin_rightBarButtonItems {
if (iOS11 && isCalledFromSystem) {
return [self _navigationitem_margin_rightBarButtonItems];
} else {
return self.originalRightBarButtonItems;
}
}
- (void)_navigationitem_margin_setRightBarButtonItems:(NSArray *)items animated:(BOOL)animated {
if (items.count) {
self.originalRightBarButtonItems = items;
UIBarButtonItem *spacer = [self rightSpacerForItem:items.firstObject];
NSArray *itemsWithMargin = [@[spacer] arrayByAddingObjectsFromArray:items];
[self _navigationitem_margin_setRightBarButtonItems:itemsWithMargin animated:animated];
} else {
self.originalRightBarButtonItems = nil;
[self _navigationitem_margin_setRightBarButtonItems:nil animated:animated];
}
}
@end
================================================
FILE: UINavigationItem+Margin.podspec
================================================
Pod::Spec.new do |s|
s.name = 'UINavigationItem+Margin'
s.version = '2.1.1'
s.summary = 'Margin for UINavigationItem.'
s.homepage = 'https://github.com/devxoul/UINavigationItem-Margin'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Suyeol Jeon' => 'devxoul@gmail.com' }
s.source = { :git => 'https://github.com/devxoul/UINavigationItem-Margin.git', :tag => s.version.to_s }
s.source_files = 'UINavigationItem+Margin/*.{h,m}'
s.frameworks = 'UIKit'
s.requires_arc = true
s.ios.deployment_target = '7.0'
end
================================================
FILE: UINavigationItem+Margin.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0344E2FC1A76497D0099CB48 /* UINavigationItem+Margin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0344E2FB1A76497D0099CB48 /* UINavigationItem+Margin.h */; settings = {ATTRIBUTES = (Public, ); }; };
0344E3091A76497D0099CB48 /* UINavigationItem_MarginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0344E3081A76497D0099CB48 /* UINavigationItem_MarginTests.m */; };
0344E3131A7649CE0099CB48 /* UINavigationItem+Margin.m in Sources */ = {isa = PBXBuildFile; fileRef = 0344E3121A7649CE0099CB48 /* UINavigationItem+Margin.m */; };
035A065D1E903C7800C4680A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 035A065C1E903C7800C4680A /* AppDelegate.swift */; };
035A065F1E903C7800C4680A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 035A065E1E903C7800C4680A /* ViewController.swift */; };
035A06621E903C7800C4680A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 035A06601E903C7800C4680A /* Main.storyboard */; };
035A06641E903C7800C4680A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 035A06631E903C7800C4680A /* Assets.xcassets */; };
035A06671E903C7800C4680A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 035A06651E903C7800C4680A /* LaunchScreen.storyboard */; };
035A066C1E903CA000C4680A /* UINavigationItem_Margin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0344E2F61A76497D0099CB48 /* UINavigationItem_Margin.framework */; };
035A066D1E903CA000C4680A /* UINavigationItem_Margin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0344E2F61A76497D0099CB48 /* UINavigationItem_Margin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
03624A911F964224005B2184 /* UINavigationBarContentView+Margin.m in Sources */ = {isa = PBXBuildFile; fileRef = 03624A901F964224005B2184 /* UINavigationBarContentView+Margin.m */; };
03A5A97A1F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.h in Headers */ = {isa = PBXBuildFile; fileRef = 03A5A9781F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.h */; settings = {ATTRIBUTES = (Public, ); }; };
03A5A97B1F95E90F002357EF /* UINavigationBarContentViewLayout+Margin.m in Sources */ = {isa = PBXBuildFile; fileRef = 03A5A9791F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.m */; };
03A5A97E1F95E9CB002357EF /* Swizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 03A5A97D1F95E9CB002357EF /* Swizzle.m */; };
03A5A97F1F95EAE6002357EF /* Swizzle.h in Headers */ = {isa = PBXBuildFile; fileRef = 03A5A97C1F95E99A002357EF /* Swizzle.h */; settings = {ATTRIBUTES = (Private, ); }; };
03A5A9951F96234D002357EF /* UINavigationItem_Margin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0344E2F61A76497D0099CB48 /* UINavigationItem_Margin.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
035A066E1E903CA000C4680A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0344E2ED1A76497D0099CB48 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0344E2F51A76497D0099CB48;
remoteInfo = "UINavigationItem+Margin";
};
03A5A9921F96230D002357EF /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0344E2ED1A76497D0099CB48 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0344E2F51A76497D0099CB48;
remoteInfo = "UINavigationItem+Margin";
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
035A06701E903CA100C4680A /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
035A066D1E903CA000C4680A /* UINavigationItem_Margin.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
0344E2F61A76497D0099CB48 /* UINavigationItem_Margin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UINavigationItem_Margin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0344E2FA1A76497D0099CB48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0344E2FB1A76497D0099CB48 /* UINavigationItem+Margin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationItem+Margin.h"; sourceTree = "<group>"; };
0344E3011A76497D0099CB48 /* UINavigationItem+MarginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UINavigationItem+MarginTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
0344E3071A76497D0099CB48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0344E3081A76497D0099CB48 /* UINavigationItem_MarginTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UINavigationItem_MarginTests.m; sourceTree = "<group>"; };
0344E3121A7649CE0099CB48 /* UINavigationItem+Margin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationItem+Margin.m"; sourceTree = "<group>"; };
035A06551E903C0400C4680A /* UINavigation+Margin.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = "UINavigation+Margin.modulemap"; sourceTree = "<group>"; };
035A065A1E903C7800C4680A /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
035A065C1E903C7800C4680A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
035A065E1E903C7800C4680A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
035A06611E903C7800C4680A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
035A06631E903C7800C4680A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
035A06661E903C7800C4680A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
035A06681E903C7800C4680A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
03624A8F1F96421A005B2184 /* UINavigationBarContentView+Margin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationBarContentView+Margin.h"; sourceTree = "<group>"; };
03624A901F964224005B2184 /* UINavigationBarContentView+Margin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBarContentView+Margin.m"; sourceTree = "<group>"; };
03A5A9781F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationBarContentViewLayout+Margin.h"; sourceTree = "<group>"; };
03A5A9791F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBarContentViewLayout+Margin.m"; sourceTree = "<group>"; };
03A5A97C1F95E99A002357EF /* Swizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Swizzle.h; sourceTree = "<group>"; };
03A5A97D1F95E9CB002357EF /* Swizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Swizzle.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0344E2F21A76497D0099CB48 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0344E2FE1A76497D0099CB48 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
03A5A9951F96234D002357EF /* UINavigationItem_Margin.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
035A06571E903C7800C4680A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
035A066C1E903CA000C4680A /* UINavigationItem_Margin.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0344E2EC1A76497D0099CB48 = {
isa = PBXGroup;
children = (
0344E2F81A76497D0099CB48 /* UINavigationItem+Margin */,
0344E3051A76497D0099CB48 /* UINavigationItem+MarginTests */,
035A065B1E903C7800C4680A /* Example */,
0344E2F71A76497D0099CB48 /* Products */,
03A5A9941F96234D002357EF /* Frameworks */,
);
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 4;
};
0344E2F71A76497D0099CB48 /* Products */ = {
isa = PBXGroup;
children = (
0344E2F61A76497D0099CB48 /* UINavigationItem_Margin.framework */,
0344E3011A76497D0099CB48 /* UINavigationItem+MarginTests.xctest */,
035A065A1E903C7800C4680A /* Example.app */,
);
name = Products;
sourceTree = "<group>";
};
0344E2F81A76497D0099CB48 /* UINavigationItem+Margin */ = {
isa = PBXGroup;
children = (
03A5A97C1F95E99A002357EF /* Swizzle.h */,
03A5A97D1F95E9CB002357EF /* Swizzle.m */,
0344E2FB1A76497D0099CB48 /* UINavigationItem+Margin.h */,
0344E3121A7649CE0099CB48 /* UINavigationItem+Margin.m */,
03624A8F1F96421A005B2184 /* UINavigationBarContentView+Margin.h */,
03624A901F964224005B2184 /* UINavigationBarContentView+Margin.m */,
03A5A9781F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.h */,
03A5A9791F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.m */,
0344E2F91A76497D0099CB48 /* Supporting Files */,
);
path = "UINavigationItem+Margin";
sourceTree = "<group>";
};
0344E2F91A76497D0099CB48 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0344E2FA1A76497D0099CB48 /* Info.plist */,
035A06551E903C0400C4680A /* UINavigation+Margin.modulemap */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
0344E3051A76497D0099CB48 /* UINavigationItem+MarginTests */ = {
isa = PBXGroup;
children = (
0344E3081A76497D0099CB48 /* UINavigationItem_MarginTests.m */,
0344E3061A76497D0099CB48 /* Supporting Files */,
);
path = "UINavigationItem+MarginTests";
sourceTree = "<group>";
};
0344E3061A76497D0099CB48 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0344E3071A76497D0099CB48 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
035A065B1E903C7800C4680A /* Example */ = {
isa = PBXGroup;
children = (
035A065C1E903C7800C4680A /* AppDelegate.swift */,
035A065E1E903C7800C4680A /* ViewController.swift */,
035A06601E903C7800C4680A /* Main.storyboard */,
035A06631E903C7800C4680A /* Assets.xcassets */,
035A06651E903C7800C4680A /* LaunchScreen.storyboard */,
035A06681E903C7800C4680A /* Info.plist */,
);
path = Example;
sourceTree = "<group>";
};
03A5A9941F96234D002357EF /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
0344E2F31A76497D0099CB48 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
03A5A97A1F95E90E002357EF /* UINavigationBarContentViewLayout+Margin.h in Headers */,
0344E2FC1A76497D0099CB48 /* UINavigationItem+Margin.h in Headers */,
03A5A97F1F95EAE6002357EF /* Swizzle.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
0344E2F51A76497D0099CB48 /* UINavigationItem+Margin */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0344E30C1A76497D0099CB48 /* Build configuration list for PBXNativeTarget "UINavigationItem+Margin" */;
buildPhases = (
0344E2F11A76497D0099CB48 /* Sources */,
0344E2F21A76497D0099CB48 /* Frameworks */,
0344E2F31A76497D0099CB48 /* Headers */,
0344E2F41A76497D0099CB48 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "UINavigationItem+Margin";
productName = "UINavigationItem+Margin";
productReference = 0344E2F61A76497D0099CB48 /* UINavigationItem_Margin.framework */;
productType = "com.apple.product-type.framework";
};
0344E3001A76497D0099CB48 /* UINavigationItem+MarginTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0344E30F1A76497D0099CB48 /* Build configuration list for PBXNativeTarget "UINavigationItem+MarginTests" */;
buildPhases = (
0344E2FD1A76497D0099CB48 /* Sources */,
0344E2FE1A76497D0099CB48 /* Frameworks */,
0344E2FF1A76497D0099CB48 /* Resources */,
);
buildRules = (
);
dependencies = (
03A5A9931F96230D002357EF /* PBXTargetDependency */,
);
name = "UINavigationItem+MarginTests";
productName = "UINavigationItem+MarginTests";
productReference = 0344E3011A76497D0099CB48 /* UINavigationItem+MarginTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
035A06591E903C7800C4680A /* Example */ = {
isa = PBXNativeTarget;
buildConfigurationList = 035A06691E903C7800C4680A /* Build configuration list for PBXNativeTarget "Example" */;
buildPhases = (
035A06561E903C7800C4680A /* Sources */,
035A06571E903C7800C4680A /* Frameworks */,
035A06581E903C7800C4680A /* Resources */,
035A06701E903CA100C4680A /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
035A066F1E903CA000C4680A /* PBXTargetDependency */,
);
name = Example;
productName = Example;
productReference = 035A065A1E903C7800C4680A /* Example.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0344E2ED1A76497D0099CB48 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Suyeol Jeon";
TargetAttributes = {
0344E2F51A76497D0099CB48 = {
CreatedOnToolsVersion = 6.2;
};
0344E3001A76497D0099CB48 = {
CreatedOnToolsVersion = 6.2;
};
035A06591E903C7800C4680A = {
CreatedOnToolsVersion = 8.3;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 0344E2F01A76497D0099CB48 /* Build configuration list for PBXProject "UINavigationItem+Margin" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0344E2EC1A76497D0099CB48;
productRefGroup = 0344E2F71A76497D0099CB48 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0344E2F51A76497D0099CB48 /* UINavigationItem+Margin */,
0344E3001A76497D0099CB48 /* UINavigationItem+MarginTests */,
035A06591E903C7800C4680A /* Example */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0344E2F41A76497D0099CB48 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0344E2FF1A76497D0099CB48 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
035A06581E903C7800C4680A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
035A06671E903C7800C4680A /* LaunchScreen.storyboard in Resources */,
035A06641E903C7800C4680A /* Assets.xcassets in Resources */,
035A06621E903C7800C4680A /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0344E2F11A76497D0099CB48 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
03624A911F964224005B2184 /* UINavigationBarContentView+Margin.m in Sources */,
03A5A97E1F95E9CB002357EF /* Swizzle.m in Sources */,
0344E3131A7649CE0099CB48 /* UINavigationItem+Margin.m in Sources */,
03A5A97B1F95E90F002357EF /* UINavigationBarContentViewLayout+Margin.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0344E2FD1A76497D0099CB48 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0344E3091A76497D0099CB48 /* UINavigationItem_MarginTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
035A06561E903C7800C4680A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
035A065F1E903C7800C4680A /* ViewController.swift in Sources */,
035A065D1E903C7800C4680A /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
035A066F1E903CA000C4680A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0344E2F51A76497D0099CB48 /* UINavigationItem+Margin */;
targetProxy = 035A066E1E903CA000C4680A /* PBXContainerItemProxy */;
};
03A5A9931F96230D002357EF /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0344E2F51A76497D0099CB48 /* UINavigationItem+Margin */;
targetProxy = 03A5A9921F96230D002357EF /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
035A06601E903C7800C4680A /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
035A06611E903C7800C4680A /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
035A06651E903C7800C4680A /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
035A06661E903C7800C4680A /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0344E30A1A76497D0099CB48 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
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_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_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
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 = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
0344E30B1A76497D0099CB48 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
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_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_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 1;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
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 = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
0344E30D1A76497D0099CB48 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "UINavigationItem+Margin/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = "UINavigationItem+Margin/UINavigation+Margin.modulemap";
PRODUCT_BUNDLE_IDENTIFIER = "kr.xoul.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = UINavigationItem_Margin;
SKIP_INSTALL = YES;
};
name = Debug;
};
0344E30E1A76497D0099CB48 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "UINavigationItem+Margin/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = "UINavigationItem+Margin/UINavigation+Margin.modulemap";
PRODUCT_BUNDLE_IDENTIFIER = "kr.xoul.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = UINavigationItem_Margin;
SKIP_INSTALL = YES;
};
name = Release;
};
0344E3101A76497D0099CB48 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = "UINavigationItem+MarginTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kr.xoul.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
0344E3111A76497D0099CB48 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = "UINavigationItem+MarginTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kr.xoul.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
035A066A1E903C7800C4680A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
035A066B1E903C7800C4680A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0344E2F01A76497D0099CB48 /* Build configuration list for PBXProject "UINavigationItem+Margin" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0344E30A1A76497D0099CB48 /* Debug */,
0344E30B1A76497D0099CB48 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0344E30C1A76497D0099CB48 /* Build configuration list for PBXNativeTarget "UINavigationItem+Margin" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0344E30D1A76497D0099CB48 /* Debug */,
0344E30E1A76497D0099CB48 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0344E30F1A76497D0099CB48 /* Build configuration list for PBXNativeTarget "UINavigationItem+MarginTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0344E3101A76497D0099CB48 /* Debug */,
0344E3111A76497D0099CB48 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
035A06691E903C7800C4680A /* Build configuration list for PBXNativeTarget "Example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
035A066A1E903C7800C4680A /* Debug */,
035A066B1E903C7800C4680A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0344E2ED1A76497D0099CB48 /* Project object */;
}
================================================
FILE: UINavigationItem+Margin.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:UINavigationItem+Margin.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: UINavigationItem+Margin.xcodeproj/xcshareddata/xcschemes/UINavigationItem+Margin.xcscheme
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0344E2F51A76497D0099CB48"
BuildableName = "UINavigationItem_Margin.framework"
BlueprintName = "UINavigationItem+Margin"
ReferencedContainer = "container:UINavigationItem+Margin.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0344E3001A76497D0099CB48"
BuildableName = "UINavigationItem+MarginTests.xctest"
BlueprintName = "UINavigationItem+MarginTests"
ReferencedContainer = "container:UINavigationItem+Margin.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0344E3001A76497D0099CB48"
BuildableName = "UINavigationItem+MarginTests.xctest"
BlueprintName = "UINavigationItem+MarginTests"
ReferencedContainer = "container:UINavigationItem+Margin.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0344E2F51A76497D0099CB48"
BuildableName = "UINavigationItem_Margin.framework"
BlueprintName = "UINavigationItem+Margin"
ReferencedContainer = "container:UINavigationItem+Margin.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0344E2F51A76497D0099CB48"
BuildableName = "UINavigationItem_Margin.framework"
BlueprintName = "UINavigationItem+Margin"
ReferencedContainer = "container:UINavigationItem+Margin.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0344E2F51A76497D0099CB48"
BuildableName = "UINavigationItem_Margin.framework"
BlueprintName = "UINavigationItem+Margin"
ReferencedContainer = "container:UINavigationItem+Margin.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
================================================
FILE: UINavigationItem+MarginTests/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>en</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>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
================================================
FILE: UINavigationItem+MarginTests/UINavigationItem_MarginTests.m
================================================
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Suyeol Jeon (xoul.kr)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import <UINavigationItem_Margin/UINavigationItem+Margin.h>
@interface UINavigationItem_MarginTests : XCTestCase
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UIViewController *viewController;
@property (nonatomic, strong) UINavigationController *navigationController;
@property (nonatomic, strong) UIBarButtonItem *editButton;
@property (nonatomic, strong) UIBarButtonItem *doneButton;
@property (nonatomic, strong) UIBarButtonItem *customButton;
@end
@implementation UINavigationItem_MarginTests
- (void)setUp
{
[super setUp];
self.viewController = [[UIViewController alloc] init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// we cannot use `-[UIWindow makeKeyAndVisible:]` on test environment.
[self.window addSubview:self.navigationController.view];
self.editButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
target:nil
action:nil];
self.doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:nil
action:nil];
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
customView.backgroundColor = [UIColor redColor];
self.customButton = [[UIBarButtonItem alloc] initWithCustomView:customView];
}
- (void)tearDown
{
self.navigationController.navigationItem.leftMargin = [UINavigationItem systemMargin];
self.navigationController.navigationItem.rightMargin = [UINavigationItem systemMargin];
[super tearDown];
}
#pragma mark -
UIView *rootViewOf(UIView *subview)
{
UIView *rootView = subview;
while (rootView.superview != nil) {
if ([rootView.superview isKindOfClass:UINavigationBar.class]) {
return rootView.superview;
}
rootView = rootView.superview;
}
return rootView;
}
CGRect relativeRect(UIBarButtonItem *barButtonItem)
{
UIButton *button = [barButtonItem valueForKey:@"view"];
UIView *rootView = rootViewOf(button);
return [rootView convertRect:button.frame fromView:button.superview];
}
CGFloat left(UIBarButtonItem *barButtonItem)
{
return ceil(CGRectGetMinX(relativeRect(barButtonItem)));
}
CGFloat right(UIBarButtonItem *barButtonItem)
{
UIButton *button = [barButtonItem valueForKey:@"view"];
UIView *rootView = rootViewOf(button);
return ceil(CGRectGetWidth(rootView.bounds) - CGRectGetMaxX(relativeRect(barButtonItem)));
}
void perform(id object, NSString *selectorName)
{
SEL selector = NSSelectorFromString(selectorName);
IMP imp = [object methodForSelector:selector];
void (*func)(id, SEL) = (void *)imp;
func(object, selector);
}
- (void)layout
{
[self.navigationController.view setNeedsLayout];
[self.navigationController.view layoutIfNeeded];
}
#pragma mark - Get/Set Items
- (void)testLeftSetItemGetItem
{
self.viewController.navigationItem.leftBarButtonItem = self.editButton;
XCTAssertEqual(self.viewController.navigationItem.leftBarButtonItem, self.editButton);
}
- (void)testLeftSetItemGetItems
{
self.viewController.navigationItem.leftBarButtonItem = self.editButton;
XCTAssertEqual(self.viewController.navigationItem.leftBarButtonItems[0], self.editButton);
}
- (void)testLeftSetItemsGetItem
{
self.viewController.navigationItem.leftBarButtonItems = @[self.editButton, self.doneButton];
XCTAssertEqual(self.viewController.navigationItem.leftBarButtonItem, self.editButton);
}
- (void)testLeftSetItemsGetItems
{
self.viewController.navigationItem.leftBarButtonItems = @[self.editButton, self.doneButton];
XCTAssertEqual(self.viewController.navigationItem.leftBarButtonItems[0], self.editButton);
}
- (void)testLeftSetNil
{
self.viewController.navigationItem.leftBarButtonItem = nil;
XCTAssertNil(self.viewController.navigationItem.leftBarButtonItem);
}
- (void)testLeftSetNilAfterSetItem
{
self.viewController.navigationItem.leftBarButtonItem = self.editButton;
self.viewController.navigationItem.leftBarButtonItem = nil;
XCTAssertNil(self.viewController.navigationItem.leftBarButtonItem);
}
- (void)testLeftSetNilAfterSetItems
{
self.viewController.navigationItem.leftBarButtonItems = @[self.editButton, self.doneButton];
self.viewController.navigationItem.leftBarButtonItem = nil;
XCTAssertNil(self.viewController.navigationItem.leftBarButtonItem);
}
- (void)testLeftSetEmptyItems
{
self.viewController.navigationItem.leftBarButtonItems = @[];
XCTAssertNil(self.viewController.navigationItem.leftBarButtonItem);
}
- (void)testRightSetItemGetItem
{
self.viewController.navigationItem.rightBarButtonItem = self.editButton;
XCTAssertEqual(self.viewController.navigationItem.rightBarButtonItem, self.editButton);
}
- (void)testRightSetItemGetItems
{
self.viewController.navigationItem.rightBarButtonItem = self.editButton;
XCTAssertEqual(self.viewController.navigationItem.rightBarButtonItems[0], self.editButton);
}
- (void)testRightSetItemsGetItem
{
self.viewController.navigationItem.rightBarButtonItems = @[self.editButton, self.doneButton];
XCTAssertEqual(self.viewController.navigationItem.rightBarButtonItem, self.editButton);
}
- (void)testRightSetItemsGetItems
{
self.viewController.navigationItem.rightBarButtonItems = @[self.editButton, self.doneButton];
XCTAssertEqual(self.viewController.navigationItem.rightBarButtonItems[0], self.editButton);
}
- (void)testRightSetNil
{
self.viewController.navigationItem.rightBarButtonItem = nil;
XCTAssertNil(self.viewController.navigationItem.rightBarButtonItem);
}
- (void)testRightSetNilAfterSetItem
{
self.viewController.navigationItem.rightBarButtonItem = self.doneButton;
self.viewController.navigationItem.rightBarButtonItem = nil;
XCTAssertNil(self.viewController.navigationItem.rightBarButtonItem);
}
- (void)testRightSetNilAfterSetItems
{
self.viewController.navigationItem.rightBarButtonItems = @[self.editButton, self.doneButton];
self.viewController.navigationItem.rightBarButtonItem = nil;
XCTAssertNil(self.viewController.navigationItem.rightBarButtonItem);
}
- (void)testRightSetEmptyItems
{
self.viewController.navigationItem.rightBarButtonItems = @[];
XCTAssertNil(self.viewController.navigationItem.rightBarButtonItem);
}
#pragma mark - Default Margin
- (void)testDefaultLeftMargin
{
XCTAssertEqual(self.viewController.navigationItem.leftMargin, [UINavigationItem systemMargin]);
}
- (void)testDefaultRightMargin
{
XCTAssertEqual(self.viewController.navigationItem.rightMargin, [UINavigationItem systemMargin]);
}
#pragma mark - UINavigationItem
- (void)testLeftMargin_UINavigationItem
{
self.viewController.navigationItem.leftMargin = 10;
self.viewController.navigationItem.leftBarButtonItem = self.editButton;
[self layout];
XCTAssertEqual(left(self.viewController.navigationItem.leftBarButtonItem), 10);
}
- (void)testRightMargin_UINavigationItem
{
self.viewController.navigationItem.rightMargin = 11;
self.viewController.navigationItem.rightBarButtonItem = self.doneButton;
[self layout];
XCTAssertEqual(right(self.viewController.navigationItem.rightBarButtonItem), 11);
}
- (void)testLeftMargin_UINavigationItem_later
{
self.viewController.navigationItem.leftBarButtonItem = self.editButton;
self.viewController.navigationItem.leftMargin = 12;
[self layout];
XCTAssertEqual(left(self.viewController.navigationItem.leftBarButtonItem), 12);
}
- (void)testRightMargin_UINavigationItem_later
{
self.viewController.navigationItem.rightMargin = 13;
self.viewController.navigationItem.rightBarButtonItem = self.doneButton;
[self layout];
XCTAssertEqual(right(self.viewController.navigationItem.rightBarButtonItem), 13);
}
#pragma mark - Custom View
- (void)testLeftMargin_customView
{
self.viewController.navigationItem.leftMargin = 10;
self.viewController.navigationItem.leftBarButtonItem = self.customButton;
[self layout];
XCTAssertEqual(left(self.viewController.navigationItem.leftBarButtonItem), 10);
}
- (void)testRightMargin_customView
{
self.viewController.navigationItem.rightMargin = 10;
self.viewController.navigationItem.rightBarButtonItem = self.customButton;
[self layout];
XCTAssertEqual(right(self.viewController.navigationItem.rightBarButtonItem), 10);
}
- (void)testLeftMargin_customView_later
{
self.viewController.navigationItem.leftBarButtonItem = self.customButton;
self.viewController.navigationItem.leftMargin = 10;
[self layout];
XCTAssertEqual(left(self.viewController.navigationItem.leftBarButtonItem), 10);
}
- (void)testRightMargin_customView_later
{
self.viewController.navigationItem.rightBarButtonItem = self.customButton;
self.viewController.navigationItem.rightMargin = 10;
[self layout];
XCTAssertEqual(right(self.viewController.navigationItem.rightBarButtonItem), 10);
}
@end
gitextract_mraiw755/
├── .gitignore
├── .travis.yml
├── Example/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ └── AppIcon.appiconset/
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
├── LICENSE
├── README.md
├── UINavigationItem+Margin/
│ ├── Info.plist
│ ├── Swizzle.h
│ ├── Swizzle.m
│ ├── UINavigation+Margin.modulemap
│ ├── UINavigationBarContentView+Margin.h
│ ├── UINavigationBarContentView+Margin.m
│ ├── UINavigationBarContentViewLayout+Margin.h
│ ├── UINavigationBarContentViewLayout+Margin.m
│ ├── UINavigationItem+Margin.h
│ └── UINavigationItem+Margin.m
├── UINavigationItem+Margin.podspec
├── UINavigationItem+Margin.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ └── xcshareddata/
│ └── xcschemes/
│ └── UINavigationItem+Margin.xcscheme
└── UINavigationItem+MarginTests/
├── Info.plist
└── UINavigationItem_MarginTests.m
Condensed preview — 26 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (81K chars).
[
{
"path": ".gitignore",
"chars": 204,
"preview": "build/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspec"
},
{
"path": ".travis.yml",
"chars": 874,
"preview": "language: objective-c\nosx_image: xcode9\nsudo: false\n\nenv:\n global:\n - PROJECT=\"UINavigationItem+Margin.xcodeproj\"\n "
},
{
"path": "Example/AppDelegate.swift",
"chars": 2111,
"preview": "//\n// AppDelegate.swift\n// Example\n//\n// Created by Suyeol Jeon on 02/04/2017.\n// Copyright © 2017 Suyeol Jeon. All "
},
{
"path": "Example/Assets.xcassets/AppIcon.appiconset/Contents.json",
"chars": 585,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"29x29\",\n \"scale\" : \"2x\"\n },\n {\n \"idiom\""
},
{
"path": "Example/Base.lproj/LaunchScreen.storyboard",
"chars": 1740,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "Example/Base.lproj/Main.storyboard",
"chars": 3325,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "Example/Info.plist",
"chars": 1152,
"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": "Example/ViewController.swift",
"chars": 374,
"preview": "//\n// ViewController.swift\n// Example\n//\n// Created by Suyeol Jeon on 02/04/2017.\n// Copyright © 2017 Suyeol Jeon. A"
},
{
"path": "LICENSE",
"chars": 1088,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Suyeol Jeon (xoul.kr)\n\nPermission is hereby granted, free of charge, to any pe"
},
{
"path": "README.md",
"chars": 1548,
"preview": "UINavigationItem+Margin\n=======================\n\n[\n//\n// Copyright (c) 2015 Suyeol Jeon (xoul.kr)\n//\n// Permission is hereby granted, free of c"
},
{
"path": "UINavigationItem+Margin/UINavigationItem+Margin.m",
"chars": 8573,
"preview": "//\n// The MIT License (MIT)\n//\n// Copyright (c) 2015 Suyeol Jeon (xoul.kr)\n//\n// Permission is hereby granted, free of c"
},
{
"path": "UINavigationItem+Margin.podspec",
"chars": 628,
"preview": "Pod::Spec.new do |s|\n s.name = 'UINavigationItem+Margin'\n s.version = '2.1.1'\n s.summary "
},
{
"path": "UINavigationItem+Margin.xcodeproj/project.pbxproj",
"chars": 28125,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "UINavigationItem+Margin.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 168,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:UINavigationIte"
},
{
"path": "UINavigationItem+Margin.xcodeproj/xcshareddata/xcschemes/UINavigationItem+Margin.xcscheme",
"chars": 4556,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n LastUpgradeVersion = \"0900\"\n version = \"1.3\">\n <BuildAction\n "
},
{
"path": "UINavigationItem+MarginTests/Info.plist",
"chars": 733,
"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": "UINavigationItem+MarginTests/UINavigationItem_MarginTests.m",
"chars": 10555,
"preview": "//\n// The MIT License (MIT)\n//\n// Copyright (c) 2015 Suyeol Jeon (xoul.kr)\n//\n// Permission is hereby granted, free of c"
}
]
About this extraction
This page contains the full source code of the devxoul/UINavigationItem-Margin GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 26 files (72.1 KB), approximately 21.0k 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.