├── .gitignore ├── DAONaviBar.podspec ├── DAONaviBar ├── DAONaviBar.h ├── DAONaviBar.m └── HTDelegateProxy │ ├── HTDelegateProxy.h │ └── HTDelegateProxy.m ├── DAONaviBarDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DAONaviBarDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Media.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── back.imageset │ │ ├── Contents.json │ │ ├── back.png │ │ ├── back@2x.png │ │ └── back@3x.png ├── TableViewController.h ├── TableViewController.m ├── WebViewController.h ├── WebViewController.m └── main.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ -------------------------------------------------------------------------------- /DAONaviBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "DAONaviBar" 3 | s.version = "0.4.6" 4 | s.summary = "DaoNaviBar is a Facebook like navigation bar with smooth auto-scrolling animation." 5 | s.homepage = "https://github.com/daoseng33/DAONaviBar" 6 | s.screenshots = "https://media.giphy.com/media/aMkjGZk8fA8HC/giphy.gif" 7 | s.license = "WTFPL" 8 | s.author = { "daoseng33" => "lc.ray2011@gmail.com" } 9 | s.platform = :ios, "8.0" 10 | s.source = { :git => "https://github.com/daoseng33/DAONaviBar.git", :tag => "#{s.version}" } 11 | s.source_files = "DAONaviBar", "DAONaviBarDemo/DAONaviBar/**/*.{h,m}" 12 | s.framework = "UIKit" 13 | s.dependency 'HTDelegateProxy', '~> 0.0.2' 14 | # s.frameworks = "SomeFramework", "AnotherFramework" 15 | end -------------------------------------------------------------------------------- /DAONaviBar/DAONaviBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // DAONaviBar.h 3 | // AlleyStore 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DAONaviBar : NSObject 12 | 13 | + (instancetype)sharedInstance; 14 | 15 | - (void)setupWithController:(UIViewController *)vc scrollView:(UIScrollView *)scrollView hideTitle:(BOOL)hideTitle; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /DAONaviBar/DAONaviBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // DAONaviBar.m 3 | // AlleyStore 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp.All rights reserved. 7 | // 8 | 9 | #import "DAONaviBar.h" 10 | #import "HTDelegateProxy.h" 11 | 12 | static CGFloat foldNaviHeight = 24.0; 13 | static CGFloat expandNaviHeight = 44.0; 14 | 15 | @interface DAONaviBar () 16 | 17 | @property (weak, nonatomic) UIViewController *vc; 18 | @property (weak, nonatomic) UIWindow *statusBarWindow; 19 | @property (strong, nonatomic) UIView *cloneBackView; 20 | @property (strong, nonatomic) UILabel *cloneTitleLabel; 21 | 22 | @property (nonatomic) CGFloat previousScrollViewYOffset; 23 | @property (nonatomic) CGRect originalBackButtonFrame; 24 | @property (nonatomic) CGRect originalTitleLabelframe; 25 | @property (assign, nonatomic) BOOL isScrollAnimating; 26 | @property (assign, nonatomic) BOOL hideTitle; 27 | @property (strong, nonatomic) HTDelegateProxy *delegateProxy; 28 | 29 | @end 30 | 31 | @implementation DAONaviBar 32 | 33 | #pragma mark - UIScrollViewDelegate 34 | 35 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 36 | if (scrollView.isDragging) { 37 | CGFloat scrollHeight = scrollView.frame.size.height; 38 | CGFloat scrollContentSizeHeight = scrollView.contentSize.height + scrollView.contentInset.bottom; 39 | CGFloat scrollOffset = scrollView.contentOffset.y; 40 | 41 | CGRect statusFrame = self.statusBarWindow.frame; 42 | CGFloat framePercentage = ((0 - statusFrame.origin.y) / CGRectGetHeight([UIApplication sharedApplication].statusBarFrame)); 43 | CGFloat scrollDiff = scrollOffset - self.previousScrollViewYOffset; 44 | 45 | if (scrollOffset <= -scrollView.contentInset.top) { 46 | [self showStatusBar:YES completion:nil]; 47 | } 48 | else if (scrollOffset + scrollHeight >= scrollContentSizeHeight) { 49 | [self showStatusBar:NO completion:nil]; 50 | } 51 | else { 52 | // 滑動速度 53 | CGFloat velocity = 40; 54 | 55 | if (scrollDiff > velocity) { 56 | [self showStatusBar:NO completion:nil]; 57 | } 58 | else if (scrollDiff < -velocity) { 59 | [self showStatusBar:YES completion:nil]; 60 | } 61 | } 62 | 63 | if (!self.isScrollAnimating) { 64 | // 數值越大滑動效果越慢 65 | CGFloat velocityLevel = 6.0; 66 | 67 | statusFrame.origin.y = MIN(0, MAX(-CGRectGetHeight([UIApplication sharedApplication].statusBarFrame), statusFrame.origin.y - (scrollDiff / velocityLevel))); 68 | self.statusBarWindow.frame = statusFrame; 69 | 70 | CGRect frame = self.vc.navigationController.navigationBar.frame; 71 | frame.origin.y = MIN(CGRectGetHeight([UIApplication sharedApplication].statusBarFrame), MAX(0, frame.origin.y - (scrollDiff / velocityLevel))); 72 | frame.size.height = MIN(expandNaviHeight, MAX(foldNaviHeight, frame.size.height - (scrollDiff / velocityLevel))); 73 | [self.vc.navigationController.navigationBar setFrame:frame]; 74 | 75 | [self updateBarButtonItems:framePercentage]; 76 | [self updateStatusBar:framePercentage]; 77 | } 78 | 79 | self.previousScrollViewYOffset = scrollOffset; 80 | } 81 | } 82 | 83 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 84 | [self stoppedScrolling]; 85 | } 86 | 87 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 88 | if (!decelerate) { 89 | [self stoppedScrolling]; 90 | } 91 | } 92 | 93 | #pragma - animation 94 | 95 | - (void)stoppedScrolling { 96 | [self showStatusBar:self.statusBarWindow.frame.origin.y >= 0 - (CGRectGetHeight([UIApplication sharedApplication].statusBarFrame) / 2) completion:nil]; 97 | } 98 | 99 | - (void)showStatusBar:(BOOL)show completion:(void (^ __nullable)(void))completion { 100 | self.isScrollAnimating = YES; 101 | 102 | CGRect statusFrame = self.statusBarWindow.frame; 103 | statusFrame.origin.y = show ? 0 : -CGRectGetHeight([UIApplication sharedApplication].statusBarFrame); 104 | 105 | CGRect frame = self.vc.navigationController.navigationBar.frame; 106 | frame.origin.y = show ? CGRectGetHeight([UIApplication sharedApplication].statusBarFrame) : 0; 107 | frame.size.height = show ? expandNaviHeight : foldNaviHeight; 108 | 109 | CGFloat percentage = show ? 0 : 1; 110 | 111 | [UIView animateWithDuration:0.2 animations:^{ 112 | self.statusBarWindow.frame = statusFrame; 113 | self.vc.navigationController.navigationBar.frame = frame; 114 | [self updateStatusBar:percentage]; 115 | [self updateBarButtonItems:percentage]; 116 | } completion:^(BOOL finished) { 117 | self.isScrollAnimating = NO; 118 | if(completion) { 119 | completion(); 120 | } 121 | }]; 122 | } 123 | 124 | - (void)updateStatusBar:(CGFloat)percentage { 125 | self.statusBarWindow.alpha = 1 - percentage; 126 | } 127 | 128 | - (void)updateBarButtonItems:(CGFloat)percentage { 129 | CGFloat diff = 1.0 - (foldNaviHeight / CGRectGetHeight(self.originalBackButtonFrame)); 130 | CGFloat scale = 1.0 - (diff * percentage); 131 | self.cloneBackView.transform = CGAffineTransformMakeScale(scale, scale); 132 | 133 | CGRect frame = self.cloneBackView.frame; 134 | 135 | CGFloat originalBottomMargin = ((expandNaviHeight - CGRectGetHeight(self.cloneBackView.frame)) / 2); 136 | CGFloat foldBottomMargin = 0.0; 137 | frame.origin.y = expandNaviHeight - CGRectGetHeight(self.cloneBackView.frame) - originalBottomMargin - ((originalBottomMargin - foldBottomMargin) * percentage); 138 | 139 | CGFloat originalLeftMargin = CGRectGetMinX(self.originalBackButtonFrame); 140 | CGFloat foldLeftMargin = 0.0; 141 | frame.origin.x = originalLeftMargin + ((foldLeftMargin - originalLeftMargin) * percentage); 142 | 143 | self.cloneBackView.frame = frame; 144 | 145 | if (self.hideTitle) { 146 | for (UIView *view in self.vc.navigationController.navigationBar.subviews) { 147 | UILabel *titleLabel; 148 | 149 | if ([NSStringFromClass([view class]) isEqualToString:@"UILabel"]) { 150 | titleLabel = (UILabel *)view; 151 | } else if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationItemView"]) { 152 | for (UILabel *label in view.subviews) { 153 | titleLabel = label; 154 | } 155 | } 156 | 157 | titleLabel.alpha = 1 - percentage; 158 | } 159 | } 160 | else { 161 | CGFloat tDiff = 1.0 - (foldNaviHeight / CGRectGetHeight(self.originalTitleLabelframe)); 162 | CGFloat tScale = 1.0 - (tDiff * percentage); 163 | self.cloneTitleLabel.transform = CGAffineTransformMakeScale(tScale, tScale); 164 | 165 | CGRect titleFrame = self.cloneTitleLabel.frame; 166 | 167 | CGFloat originalTitleBottomMargin = ((expandNaviHeight - CGRectGetHeight(self.cloneTitleLabel.frame)) / 2); 168 | CGFloat foldTitleBottomMargin = 0.0; 169 | titleFrame.origin.y = expandNaviHeight - CGRectGetHeight(self.cloneTitleLabel.frame) - originalTitleBottomMargin - ((originalTitleBottomMargin - foldTitleBottomMargin) * percentage); 170 | 171 | self.cloneTitleLabel.frame = titleFrame; 172 | } 173 | 174 | } 175 | 176 | #pragma mark - misc 177 | 178 | - (void)tap:(UITapGestureRecognizer *)sender { 179 | [self showStatusBar:YES completion:nil]; 180 | } 181 | 182 | - (void)back:(UITapGestureRecognizer *)sender { 183 | [self showStatusBar:YES completion:^ { 184 | [self resetToDefault]; 185 | 186 | if ([self isModal]) { 187 | [self.vc dismissViewControllerAnimated:YES completion:nil]; 188 | } 189 | else { 190 | [self.vc.navigationController popViewControllerAnimated:YES]; 191 | } 192 | }]; 193 | } 194 | 195 | - (void)resetToDefault { 196 | for (UIView *view in self.vc.navigationController.navigationBar.subviews) { 197 | if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationButton"]) { 198 | view.alpha = 1.0; 199 | [self.cloneBackView removeFromSuperview]; 200 | } else if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationItemView"] && !self.hideTitle) { 201 | for (UILabel *label in view.subviews) { 202 | [self.cloneTitleLabel removeFromSuperview]; 203 | label.alpha = 1.0; 204 | } 205 | } 206 | } 207 | } 208 | 209 | - (BOOL)isModal { 210 | if([self.vc presentingViewController]) 211 | return YES; 212 | if([[[self.vc navigationController] presentingViewController] presentedViewController] == [self.vc navigationController]) 213 | return YES; 214 | if([[[self.vc tabBarController] presentingViewController] isKindOfClass:[UITabBarController class]]) 215 | return YES; 216 | 217 | return NO; 218 | } 219 | 220 | #pragma mark - init values 221 | 222 | + (instancetype)sharedInstance { 223 | static DAONaviBar *instance = nil; 224 | static dispatch_once_t onceToken; 225 | dispatch_once(&onceToken, ^{ 226 | instance = [[DAONaviBar alloc] init]; 227 | }); 228 | return instance; 229 | } 230 | 231 | - (void)setupWithController:(UIViewController *)vc scrollView:(UIScrollView *)scrollView hideTitle:(BOOL)hideTitle { 232 | self.vc = vc; 233 | self.hideTitle = hideTitle; 234 | self.delegateProxy = [[HTDelegateProxy alloc] initWithDelegates:@[self, vc]]; 235 | scrollView.delegate = (id)self.delegateProxy; 236 | 237 | [self setupInitValues]; 238 | [self setupCloneView]; 239 | } 240 | 241 | - (void)setupInitValues { 242 | self.statusBarWindow = (UIWindow *)[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]; 243 | UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]; 244 | [self.vc.navigationController.navigationBar addGestureRecognizer:tapGR]; 245 | } 246 | 247 | - (void)setupCloneView { 248 | for (UIView *view in self.vc.navigationController.navigationBar.subviews) { 249 | if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationButton"]) { 250 | self.cloneBackView = [[UIView alloc] initWithFrame:view.frame]; 251 | self.originalBackButtonFrame = view.frame; 252 | 253 | for (UIImageView *imageView in view.subviews) { 254 | imageView.contentMode = UIViewContentModeScaleAspectFit; 255 | UIImageView *newImageView = [[UIImageView alloc] initWithFrame:imageView.frame]; 256 | newImageView.contentMode = UIViewContentModeScaleAspectFit; 257 | newImageView.image = imageView.image; 258 | newImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; 259 | [self.cloneBackView addSubview:newImageView]; 260 | } 261 | 262 | UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(back:)]; 263 | [self.cloneBackView addGestureRecognizer:tapGR]; 264 | [self.vc.navigationController.navigationBar addSubview:self.cloneBackView]; 265 | view.alpha = 0; 266 | 267 | } 268 | 269 | if (!self.hideTitle) { 270 | UILabel *titleLabel; 271 | 272 | if ([NSStringFromClass([view class]) isEqualToString:@"UILabel"]) { 273 | titleLabel = (UILabel *)view; 274 | } else if ([NSStringFromClass([view class]) isEqualToString:@"UINavigationItemView"]) { 275 | for (UILabel *label in view.subviews) { 276 | titleLabel = label; 277 | } 278 | } 279 | 280 | if (titleLabel) { 281 | self.originalTitleLabelframe = view.frame; 282 | self.cloneTitleLabel = [[UILabel alloc] initWithFrame:view.frame]; 283 | self.cloneTitleLabel.text = titleLabel.text; 284 | self.cloneTitleLabel.font = titleLabel.font; 285 | self.cloneTitleLabel.textColor = titleLabel.textColor; 286 | self.cloneTitleLabel.adjustsFontSizeToFitWidth = titleLabel.adjustsFontSizeToFitWidth; 287 | [self.vc.navigationController.navigationBar addSubview:self.cloneTitleLabel]; 288 | titleLabel.alpha = 0.0; 289 | } 290 | } 291 | 292 | } 293 | } 294 | 295 | @end 296 | -------------------------------------------------------------------------------- /DAONaviBar/HTDelegateProxy/HTDelegateProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTDelegateProxy.h 3 | // HotelTonight 4 | // 5 | // Created by Jacob Jennings on 10/21/12. 6 | // Copyright (c) 2012 Hotel Tonight. All rights reserved. 7 | // 8 | /* 9 | Copyright (c) 2012 Hotel Tonight 10 | 11 | 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: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | 15 | 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. 16 | */ 17 | 18 | // Void return type selectors will be invoked on all delegates that respond to the selector 19 | // Non-void return type selectors will be invoked on the first delegate in the list that responds to the selector 20 | 21 | #import 22 | 23 | @interface HTDelegateProxy : NSProxy 24 | 25 | @property (nonatomic, strong) NSArray *delegates; 26 | 27 | - (id)initWithDelegates:(NSArray *)delegates; 28 | - (id)init; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /DAONaviBar/HTDelegateProxy/HTDelegateProxy.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTDelegateProxy.m 3 | // HotelTonight 4 | // 5 | // Created by Jacob Jennings on 10/21/12. 6 | // Copyright (c) 2012 Hotel Tonight. All rights reserved. 7 | // 8 | /* 9 | Copyright (c) 2012 Hotel Tonight 10 | 11 | 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: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | 15 | 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. 16 | */ 17 | 18 | #import "HTDelegateProxy.h" 19 | 20 | @implementation HTDelegateProxy 21 | 22 | @synthesize delegates = _delegates; 23 | 24 | - (id)initWithDelegates:(NSArray *)delegates 25 | { 26 | [self setDelegates:delegates]; 27 | return self; 28 | } 29 | 30 | - (id)init 31 | { 32 | return self; 33 | } 34 | 35 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector 36 | { 37 | NSMethodSignature *signature; 38 | for (NSValue *nonRetainedValue in _delegates) 39 | { 40 | id delegate = [nonRetainedValue nonretainedObjectValue]; 41 | signature = [[delegate class] instanceMethodSignatureForSelector:selector]; 42 | if (signature) 43 | { 44 | break; 45 | } 46 | } 47 | return signature; 48 | } 49 | 50 | - (void)forwardInvocation:(NSInvocation *)invocation 51 | { 52 | NSString *returnType = [NSString stringWithCString:invocation.methodSignature.methodReturnType encoding:NSUTF8StringEncoding]; 53 | BOOL voidReturnType = [returnType isEqualToString:@"v"]; 54 | 55 | for (NSValue *nonRetainedValue in _delegates) 56 | { 57 | id delegate = [nonRetainedValue nonretainedObjectValue]; 58 | if ([delegate respondsToSelector:invocation.selector]) 59 | { 60 | [invocation invokeWithTarget:delegate]; 61 | if (!voidReturnType) 62 | { 63 | return; 64 | } 65 | } 66 | } 67 | } 68 | 69 | - (BOOL)respondsToSelector:(SEL)aSelector 70 | { 71 | for (NSValue *nonRetainedValue in _delegates) 72 | { 73 | id delegate = [nonRetainedValue nonretainedObjectValue]; 74 | if ([delegate respondsToSelector:aSelector]) 75 | { 76 | if ([delegate isKindOfClass:[UITextField class]] 77 | && [[UITextField class] instancesRespondToSelector:aSelector]) 78 | { 79 | continue; 80 | } 81 | return YES; 82 | } 83 | } 84 | return NO; 85 | } 86 | 87 | #pragma mark - Properties 88 | 89 | - (NSArray *)delegates 90 | { 91 | NSMutableArray *delegatesBuilder = [NSMutableArray arrayWithCapacity:[_delegates count]]; 92 | for (NSValue *delegateValue in _delegates) 93 | { 94 | [delegatesBuilder addObject:[delegateValue nonretainedObjectValue]]; 95 | } 96 | return [NSArray arrayWithArray:delegatesBuilder]; 97 | } 98 | 99 | - (void)setDelegates:(NSArray *)delegates 100 | { 101 | NSMutableArray *delegatesUnretainedBuilder = [NSMutableArray arrayWithCapacity:[delegates count]]; 102 | for (id delegate in delegates) 103 | { 104 | [delegatesUnretainedBuilder addObject:[NSValue valueWithNonretainedObject:delegate]]; 105 | } 106 | _delegates = [NSArray arrayWithArray:delegatesUnretainedBuilder]; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /DAONaviBarDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B986F0821F299C4200A0D8A9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B986F0711F299C4200A0D8A9 /* AppDelegate.m */; }; 11 | B986F0831F299C4200A0D8A9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B986F0721F299C4200A0D8A9 /* LaunchScreen.storyboard */; }; 12 | B986F0841F299C4200A0D8A9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B986F0741F299C4200A0D8A9 /* Main.storyboard */; }; 13 | B986F0871F299C4200A0D8A9 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B986F07B1F299C4200A0D8A9 /* Info.plist */; }; 14 | B986F0881F299C4200A0D8A9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B986F07C1F299C4200A0D8A9 /* main.m */; }; 15 | B986F0891F299C4200A0D8A9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B986F07D1F299C4200A0D8A9 /* Media.xcassets */; }; 16 | B986F08A1F299C4200A0D8A9 /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B986F07F1F299C4200A0D8A9 /* TableViewController.m */; }; 17 | B986F08B1F299C4200A0D8A9 /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B986F0811F299C4200A0D8A9 /* WebViewController.m */; }; 18 | B986F0A51F29ED5300A0D8A9 /* DAONaviBar.m in Sources */ = {isa = PBXBuildFile; fileRef = B986F0A11F29ED5300A0D8A9 /* DAONaviBar.m */; }; 19 | B986F0A61F29ED5300A0D8A9 /* HTDelegateProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B986F0A41F29ED5300A0D8A9 /* HTDelegateProxy.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | B986F03A1F288C5F00A0D8A9 /* DAONaviBarDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DAONaviBarDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | B986F0701F299C4200A0D8A9 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | B986F0711F299C4200A0D8A9 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | B986F0731F299C4200A0D8A9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | B986F0751F299C4200A0D8A9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | B986F07B1F299C4200A0D8A9 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | B986F07C1F299C4200A0D8A9 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | B986F07D1F299C4200A0D8A9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = ""; }; 31 | B986F07E1F299C4200A0D8A9 /* TableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewController.h; sourceTree = ""; }; 32 | B986F07F1F299C4200A0D8A9 /* TableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewController.m; sourceTree = ""; }; 33 | B986F0801F299C4200A0D8A9 /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = ""; }; 34 | B986F0811F299C4200A0D8A9 /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = ""; }; 35 | B986F0A01F29ED5300A0D8A9 /* DAONaviBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DAONaviBar.h; sourceTree = ""; }; 36 | B986F0A11F29ED5300A0D8A9 /* DAONaviBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DAONaviBar.m; sourceTree = ""; }; 37 | B986F0A31F29ED5300A0D8A9 /* HTDelegateProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTDelegateProxy.h; sourceTree = ""; }; 38 | B986F0A41F29ED5300A0D8A9 /* HTDelegateProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTDelegateProxy.m; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | B986F0371F288C5F00A0D8A9 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | B986F0311F288C5F00A0D8A9 = { 53 | isa = PBXGroup; 54 | children = ( 55 | B986F09F1F29ED5300A0D8A9 /* DAONaviBar */, 56 | B986F06F1F299C4200A0D8A9 /* DAONaviBarDemo */, 57 | B986F03B1F288C5F00A0D8A9 /* Products */, 58 | ); 59 | sourceTree = ""; 60 | }; 61 | B986F03B1F288C5F00A0D8A9 /* Products */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | B986F03A1F288C5F00A0D8A9 /* DAONaviBarDemo.app */, 65 | ); 66 | name = Products; 67 | sourceTree = ""; 68 | }; 69 | B986F06F1F299C4200A0D8A9 /* DAONaviBarDemo */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | B986F07E1F299C4200A0D8A9 /* TableViewController.h */, 73 | B986F07F1F299C4200A0D8A9 /* TableViewController.m */, 74 | B986F0801F299C4200A0D8A9 /* WebViewController.h */, 75 | B986F0811F299C4200A0D8A9 /* WebViewController.m */, 76 | B986F08C1F299D2F00A0D8A9 /* SupportingFiles */, 77 | ); 78 | path = DAONaviBarDemo; 79 | sourceTree = ""; 80 | }; 81 | B986F08C1F299D2F00A0D8A9 /* SupportingFiles */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | B986F0701F299C4200A0D8A9 /* AppDelegate.h */, 85 | B986F0711F299C4200A0D8A9 /* AppDelegate.m */, 86 | B986F0721F299C4200A0D8A9 /* LaunchScreen.storyboard */, 87 | B986F0741F299C4200A0D8A9 /* Main.storyboard */, 88 | B986F07B1F299C4200A0D8A9 /* Info.plist */, 89 | B986F07C1F299C4200A0D8A9 /* main.m */, 90 | B986F07D1F299C4200A0D8A9 /* Media.xcassets */, 91 | ); 92 | name = SupportingFiles; 93 | sourceTree = ""; 94 | }; 95 | B986F09F1F29ED5300A0D8A9 /* DAONaviBar */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | B986F0A01F29ED5300A0D8A9 /* DAONaviBar.h */, 99 | B986F0A11F29ED5300A0D8A9 /* DAONaviBar.m */, 100 | B986F0A21F29ED5300A0D8A9 /* HTDelegateProxy */, 101 | ); 102 | path = DAONaviBar; 103 | sourceTree = ""; 104 | }; 105 | B986F0A21F29ED5300A0D8A9 /* HTDelegateProxy */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | B986F0A31F29ED5300A0D8A9 /* HTDelegateProxy.h */, 109 | B986F0A41F29ED5300A0D8A9 /* HTDelegateProxy.m */, 110 | ); 111 | path = HTDelegateProxy; 112 | sourceTree = ""; 113 | }; 114 | /* End PBXGroup section */ 115 | 116 | /* Begin PBXNativeTarget section */ 117 | B986F0391F288C5F00A0D8A9 /* DAONaviBarDemo */ = { 118 | isa = PBXNativeTarget; 119 | buildConfigurationList = B986F0511F288C6000A0D8A9 /* Build configuration list for PBXNativeTarget "DAONaviBarDemo" */; 120 | buildPhases = ( 121 | B986F0361F288C5F00A0D8A9 /* Sources */, 122 | B986F0371F288C5F00A0D8A9 /* Frameworks */, 123 | B986F0381F288C5F00A0D8A9 /* Resources */, 124 | ); 125 | buildRules = ( 126 | ); 127 | dependencies = ( 128 | ); 129 | name = DAONaviBarDemo; 130 | productName = DAONaviBar; 131 | productReference = B986F03A1F288C5F00A0D8A9 /* DAONaviBarDemo.app */; 132 | productType = "com.apple.product-type.application"; 133 | }; 134 | /* End PBXNativeTarget section */ 135 | 136 | /* Begin PBXProject section */ 137 | B986F0321F288C5F00A0D8A9 /* Project object */ = { 138 | isa = PBXProject; 139 | attributes = { 140 | LastUpgradeCheck = 0830; 141 | ORGANIZATIONNAME = LikeABossApp; 142 | TargetAttributes = { 143 | B986F0391F288C5F00A0D8A9 = { 144 | CreatedOnToolsVersion = 8.3.3; 145 | ProvisioningStyle = Automatic; 146 | }; 147 | }; 148 | }; 149 | buildConfigurationList = B986F0351F288C5F00A0D8A9 /* Build configuration list for PBXProject "DAONaviBarDemo" */; 150 | compatibilityVersion = "Xcode 3.2"; 151 | developmentRegion = English; 152 | hasScannedForEncodings = 0; 153 | knownRegions = ( 154 | en, 155 | Base, 156 | ); 157 | mainGroup = B986F0311F288C5F00A0D8A9; 158 | productRefGroup = B986F03B1F288C5F00A0D8A9 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | B986F0391F288C5F00A0D8A9 /* DAONaviBarDemo */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | B986F0381F288C5F00A0D8A9 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | B986F0831F299C4200A0D8A9 /* LaunchScreen.storyboard in Resources */, 173 | B986F0841F299C4200A0D8A9 /* Main.storyboard in Resources */, 174 | B986F0891F299C4200A0D8A9 /* Media.xcassets in Resources */, 175 | B986F0871F299C4200A0D8A9 /* Info.plist in Resources */, 176 | ); 177 | runOnlyForDeploymentPostprocessing = 0; 178 | }; 179 | /* End PBXResourcesBuildPhase section */ 180 | 181 | /* Begin PBXSourcesBuildPhase section */ 182 | B986F0361F288C5F00A0D8A9 /* Sources */ = { 183 | isa = PBXSourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | B986F08B1F299C4200A0D8A9 /* WebViewController.m in Sources */, 187 | B986F0A61F29ED5300A0D8A9 /* HTDelegateProxy.m in Sources */, 188 | B986F0881F299C4200A0D8A9 /* main.m in Sources */, 189 | B986F08A1F299C4200A0D8A9 /* TableViewController.m in Sources */, 190 | B986F0A51F29ED5300A0D8A9 /* DAONaviBar.m in Sources */, 191 | B986F0821F299C4200A0D8A9 /* AppDelegate.m in Sources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXSourcesBuildPhase section */ 196 | 197 | /* Begin PBXVariantGroup section */ 198 | B986F0721F299C4200A0D8A9 /* LaunchScreen.storyboard */ = { 199 | isa = PBXVariantGroup; 200 | children = ( 201 | B986F0731F299C4200A0D8A9 /* Base */, 202 | ); 203 | name = LaunchScreen.storyboard; 204 | sourceTree = ""; 205 | }; 206 | B986F0741F299C4200A0D8A9 /* Main.storyboard */ = { 207 | isa = PBXVariantGroup; 208 | children = ( 209 | B986F0751F299C4200A0D8A9 /* Base */, 210 | ); 211 | name = Main.storyboard; 212 | sourceTree = ""; 213 | }; 214 | /* End PBXVariantGroup section */ 215 | 216 | /* Begin XCBuildConfiguration section */ 217 | B986F04F1F288C6000A0D8A9 /* Debug */ = { 218 | isa = XCBuildConfiguration; 219 | buildSettings = { 220 | ALWAYS_SEARCH_USER_PATHS = NO; 221 | CLANG_ANALYZER_NONNULL = YES; 222 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 224 | CLANG_CXX_LIBRARY = "libc++"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_WARN_BOOL_CONVERSION = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 230 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 231 | CLANG_WARN_EMPTY_BODY = YES; 232 | CLANG_WARN_ENUM_CONVERSION = YES; 233 | CLANG_WARN_INFINITE_RECURSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 236 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 237 | CLANG_WARN_UNREACHABLE_CODE = YES; 238 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 239 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 240 | COPY_PHASE_STRIP = NO; 241 | DEBUG_INFORMATION_FORMAT = dwarf; 242 | ENABLE_STRICT_OBJC_MSGSEND = YES; 243 | ENABLE_TESTABILITY = YES; 244 | GCC_C_LANGUAGE_STANDARD = gnu99; 245 | GCC_DYNAMIC_NO_PIC = NO; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_OPTIMIZATION_LEVEL = 0; 248 | GCC_PREPROCESSOR_DEFINITIONS = ( 249 | "DEBUG=1", 250 | "$(inherited)", 251 | ); 252 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 253 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 254 | GCC_WARN_UNDECLARED_SELECTOR = YES; 255 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 256 | GCC_WARN_UNUSED_FUNCTION = YES; 257 | GCC_WARN_UNUSED_VARIABLE = YES; 258 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 259 | MTL_ENABLE_DEBUG_INFO = YES; 260 | ONLY_ACTIVE_ARCH = YES; 261 | SDKROOT = iphoneos; 262 | TARGETED_DEVICE_FAMILY = "1,2"; 263 | }; 264 | name = Debug; 265 | }; 266 | B986F0501F288C6000A0D8A9 /* Release */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ALWAYS_SEARCH_USER_PATHS = NO; 270 | CLANG_ANALYZER_NONNULL = YES; 271 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_MODULES = YES; 275 | CLANG_ENABLE_OBJC_ARC = YES; 276 | CLANG_WARN_BOOL_CONVERSION = YES; 277 | CLANG_WARN_CONSTANT_CONVERSION = YES; 278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 279 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 280 | CLANG_WARN_EMPTY_BODY = YES; 281 | CLANG_WARN_ENUM_CONVERSION = YES; 282 | CLANG_WARN_INFINITE_RECURSION = YES; 283 | CLANG_WARN_INT_CONVERSION = YES; 284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 285 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 286 | CLANG_WARN_UNREACHABLE_CODE = YES; 287 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 288 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 289 | COPY_PHASE_STRIP = NO; 290 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 291 | ENABLE_NS_ASSERTIONS = NO; 292 | ENABLE_STRICT_OBJC_MSGSEND = YES; 293 | GCC_C_LANGUAGE_STANDARD = gnu99; 294 | GCC_NO_COMMON_BLOCKS = YES; 295 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 296 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 297 | GCC_WARN_UNDECLARED_SELECTOR = YES; 298 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 299 | GCC_WARN_UNUSED_FUNCTION = YES; 300 | GCC_WARN_UNUSED_VARIABLE = YES; 301 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 302 | MTL_ENABLE_DEBUG_INFO = NO; 303 | SDKROOT = iphoneos; 304 | TARGETED_DEVICE_FAMILY = "1,2"; 305 | VALIDATE_PRODUCT = YES; 306 | }; 307 | name = Release; 308 | }; 309 | B986F0521F288C6000A0D8A9 /* Debug */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 314 | DEVELOPMENT_TEAM = ""; 315 | INFOPLIST_FILE = "$(SRCROOT)/DAONaviBarDemo/Info.plist"; 316 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 317 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 318 | PRODUCT_BUNDLE_IDENTIFIER = com.likeabossapp.DAONaviBar; 319 | PRODUCT_NAME = "$(TARGET_NAME)"; 320 | PROVISIONING_PROFILE_SPECIFIER = ""; 321 | }; 322 | name = Debug; 323 | }; 324 | B986F0531F288C6000A0D8A9 /* Release */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 328 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 329 | DEVELOPMENT_TEAM = ""; 330 | INFOPLIST_FILE = "$(SRCROOT)/DAONaviBarDemo/Info.plist"; 331 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 332 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 333 | PRODUCT_BUNDLE_IDENTIFIER = com.likeabossapp.DAONaviBar; 334 | PRODUCT_NAME = "$(TARGET_NAME)"; 335 | PROVISIONING_PROFILE_SPECIFIER = ""; 336 | }; 337 | name = Release; 338 | }; 339 | /* End XCBuildConfiguration section */ 340 | 341 | /* Begin XCConfigurationList section */ 342 | B986F0351F288C5F00A0D8A9 /* Build configuration list for PBXProject "DAONaviBarDemo" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | B986F04F1F288C6000A0D8A9 /* Debug */, 346 | B986F0501F288C6000A0D8A9 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | B986F0511F288C6000A0D8A9 /* Build configuration list for PBXNativeTarget "DAONaviBarDemo" */ = { 352 | isa = XCConfigurationList; 353 | buildConfigurations = ( 354 | B986F0521F288C6000A0D8A9 /* Debug */, 355 | B986F0531F288C6000A0D8A9 /* Release */, 356 | ); 357 | defaultConfigurationIsVisible = 0; 358 | defaultConfigurationName = Release; 359 | }; 360 | /* End XCConfigurationList section */ 361 | }; 362 | rootObject = B986F0321F288C5F00A0D8A9 /* Project object */; 363 | } 364 | -------------------------------------------------------------------------------- /DAONaviBarDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DAONaviBarDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /DAONaviBarDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /DAONaviBarDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DAONaviBarDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /DAONaviBarDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | NSAppTransportSecurity 43 | 44 | NSAllowsArbitraryLoads 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /DAONaviBarDemo/Media.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "29x29", 26 | "scale" : "3x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "40x40", 36 | "scale" : "3x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "57x57", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "iphone", 45 | "size" : "57x57", 46 | "scale" : "2x" 47 | }, 48 | { 49 | "idiom" : "iphone", 50 | "size" : "60x60", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "iphone", 55 | "size" : "60x60", 56 | "scale" : "3x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "20x20", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "20x20", 66 | "scale" : "2x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "29x29", 71 | "scale" : "1x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "29x29", 76 | "scale" : "2x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "40x40", 81 | "scale" : "1x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "40x40", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ipad", 90 | "size" : "50x50", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "idiom" : "ipad", 95 | "size" : "50x50", 96 | "scale" : "2x" 97 | }, 98 | { 99 | "idiom" : "ipad", 100 | "size" : "72x72", 101 | "scale" : "1x" 102 | }, 103 | { 104 | "idiom" : "ipad", 105 | "size" : "72x72", 106 | "scale" : "2x" 107 | }, 108 | { 109 | "idiom" : "ipad", 110 | "size" : "76x76", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "idiom" : "ipad", 115 | "size" : "76x76", 116 | "scale" : "2x" 117 | }, 118 | { 119 | "idiom" : "ipad", 120 | "size" : "83.5x83.5", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /DAONaviBarDemo/Media.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /DAONaviBarDemo/Media.xcassets/back.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "back.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "back@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "back@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /DAONaviBarDemo/Media.xcassets/back.imageset/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daoseng33/DAONaviBar/d09c6e31bc193e868284de939b35831f60a16078/DAONaviBarDemo/Media.xcassets/back.imageset/back.png -------------------------------------------------------------------------------- /DAONaviBarDemo/Media.xcassets/back.imageset/back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daoseng33/DAONaviBar/d09c6e31bc193e868284de939b35831f60a16078/DAONaviBarDemo/Media.xcassets/back.imageset/back@2x.png -------------------------------------------------------------------------------- /DAONaviBarDemo/Media.xcassets/back.imageset/back@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daoseng33/DAONaviBar/d09c6e31bc193e868284de939b35831f60a16078/DAONaviBarDemo/Media.xcassets/back.imageset/back@3x.png -------------------------------------------------------------------------------- /DAONaviBarDemo/TableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.h 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TableViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DAONaviBarDemo/TableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.m 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import "TableViewController.h" 10 | #import "WebViewController.h" 11 | #import "DAONaviBar.h" 12 | 13 | typedef NS_ENUM (NSInteger, NaviBarType) { 14 | NaviBarTypeOriginal = 0, 15 | NaviBarTypeShowTitle, 16 | NaviBarTypeHideTitle 17 | }; 18 | 19 | @interface TableViewController () 20 | 21 | @end 22 | 23 | @implementation TableViewController 24 | 25 | #pragma mark - Table view data source 26 | 27 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 28 | return 3; 29 | } 30 | 31 | #pragma mark - Table view delegate 32 | 33 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 34 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 35 | 36 | switch ((NaviBarType)indexPath.row) { 37 | case NaviBarTypeOriginal: 38 | cell.textLabel.text = @"original navi bar"; 39 | break; 40 | 41 | case NaviBarTypeShowTitle: 42 | cell.textLabel.text = @"smooooth navi bar - show title"; 43 | break; 44 | 45 | case NaviBarTypeHideTitle: 46 | cell.textLabel.text = @"smooooth navi bar - hide title"; 47 | default: 48 | break; 49 | } 50 | 51 | return cell; 52 | } 53 | 54 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 55 | WebViewController *vc = [WebViewController new]; 56 | vc.url = @"http://apple.com"; 57 | switch ((NaviBarType)indexPath.row) { 58 | case NaviBarTypeOriginal: { 59 | vc.title = @"Original navi"; 60 | vc.isOriginal = YES; 61 | break; 62 | } 63 | 64 | case NaviBarTypeShowTitle: { 65 | vc.title = @"smooooth navi"; 66 | vc.isOriginal = NO; 67 | vc.hideTitle = NO; 68 | break; 69 | } 70 | 71 | case NaviBarTypeHideTitle: { 72 | vc.title = @"smooooth navi"; 73 | vc.isOriginal = NO; 74 | vc.hideTitle = YES; 75 | } 76 | 77 | default: 78 | break; 79 | } 80 | 81 | [self.navigationController pushViewController:vc animated:YES]; 82 | } 83 | 84 | #pragma life cycle 85 | 86 | - (void)viewDidLoad { 87 | [super viewDidLoad]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /DAONaviBarDemo/WebViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewController.h 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WebViewController : UIViewController 12 | 13 | @property (nonatomic) BOOL isOriginal; 14 | @property (nonatomic) BOOL hideTitle; 15 | @property (strong, nonatomic) NSString *url; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /DAONaviBarDemo/WebViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewController.m 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import "WebViewController.h" 10 | #import 11 | #import "DAONaviBar.h" 12 | 13 | @interface WebViewController () 14 | 15 | @property (strong, nonatomic) WKWebView *webView; 16 | 17 | @end 18 | 19 | @implementation WebViewController 20 | 21 | - (void)setupInitValues { 22 | self.automaticallyAdjustsScrollViewInsets = NO; 23 | } 24 | 25 | - (void)setupWebView { 26 | WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init]; 27 | self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:theConfiguration]; 28 | self.webView.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0); 29 | 30 | NSURL *nsurl = [NSURL URLWithString:self.url]; 31 | NSURLRequest *nsrequest = [NSURLRequest requestWithURL:nsurl]; 32 | [self.webView loadRequest:nsrequest]; 33 | [self.view addSubview:self.webView]; 34 | } 35 | 36 | #pragma mark - setup 37 | 38 | - (void)setupDefaultBackButton { 39 | UIImage *image = [[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 40 | UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(back)]; 41 | self.navigationItem.leftBarButtonItem = backButton; 42 | } 43 | 44 | - (void)setupDAONaviBar { 45 | [[DAONaviBar sharedInstance] setupWithController:self scrollView:self.webView.scrollView hideTitle:self.hideTitle]; 46 | } 47 | 48 | #pragma mark - misc 49 | 50 | - (void)back { 51 | [self.navigationController popViewControllerAnimated:YES]; 52 | } 53 | 54 | #pragma mark - life cycle 55 | 56 | - (void)viewDidLoad { 57 | [super viewDidLoad]; 58 | [self setupInitValues]; 59 | [self setupWebView]; 60 | [self setupDefaultBackButton]; 61 | } 62 | 63 | - (void)viewDidAppear:(BOOL)animated { 64 | [super viewDidAppear:animated]; 65 | if (!self.isOriginal) { 66 | [self setupDAONaviBar]; 67 | } 68 | } 69 | 70 | - (void)dealloc { 71 | self.webView.scrollView.delegate = nil; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /DAONaviBarDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DAONaviBar 4 | // 5 | // Created by daoseng on 2017/7/26. 6 | // Copyright © 2017年 LikeABossApp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2017 DaoSeng 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DAONaviBar 2 | DAONaviBar is a Facebook like navigation bar with smooth auto-scrolling animation. 3 | 4 | 1. Show title mode 5 | 6 | ![Image of navibar](https://media.giphy.com/media/3o7aCUBZMeE0SEwYX6/giphy.gif) 7 | 8 | 2. Hide title mode 9 | 10 | ![Image of navibar](https://media.giphy.com/media/aMkjGZk8fA8HC/giphy.gif) 11 | 12 | ## Requirement ## 13 | - iOS 8.0 14 | 15 | ## Installation ## 16 | ### CocoaPods ### 17 | ``` 18 | pod 'DAONaviBar', '~> 0.4.6' 19 | ``` 20 | 21 | ## Usage ## 22 | 1. Import DAONaviBar first 23 | ```objective-c 24 | #import "DAONaviBar.h" 25 | ``` 26 | 27 | 2. Just need one line in viewDidAppear 28 | ```objective-c 29 | - (void)viewDidAppear:(BOOL)animated { 30 | [super viewDidAppear:animated]; 31 | [[DAONaviBar sharedInstance] setupWithController:self scrollView:self.scrollViewToTrack hideTitle:NO]; 32 | } 33 | ``` 34 | --------------------------------------------------------------------------------