From 4fc32ffad12f9a9ca6d8ba651966d3dfb5b9947c Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kawashima Date: Thu, 11 Dec 2014 20:53:49 +0900 Subject: [PATCH 1/4] Added barsTranslucent property to SVModalWebViewController fixes #116 --- Demo/Classes/ViewController.m | 1 + SVWebViewController/SVModalWebViewController.h | 1 + SVWebViewController/SVModalWebViewController.m | 1 + SVWebViewController/SVWebViewController.m | 2 ++ 4 files changed, 5 insertions(+) diff --git a/Demo/Classes/ViewController.m b/Demo/Classes/ViewController.m index a074f4d..6f736cc 100644 --- a/Demo/Classes/ViewController.m +++ b/Demo/Classes/ViewController.m @@ -24,6 +24,7 @@ - (void)presentWebViewController { NSURL *URL = [NSURL URLWithString:@"http://samvermette.com"]; SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithURL:URL]; webViewController.modalPresentationStyle = UIModalPresentationPageSheet; + webViewController.barsTranslucent = NO; [self presentViewController:webViewController animated:YES completion:NULL]; } diff --git a/SVWebViewController/SVModalWebViewController.h b/SVWebViewController/SVModalWebViewController.h index c8ff5ca..53f0f5d 100644 --- a/SVWebViewController/SVModalWebViewController.h +++ b/SVWebViewController/SVModalWebViewController.h @@ -15,5 +15,6 @@ - (instancetype)initWithURLRequest:(NSURLRequest *)request; @property (nonatomic, strong) UIColor *barsTintColor; +@property (nonatomic, assign, getter=isBarsTranslucent) BOOL barsTranslucent; @end diff --git a/SVWebViewController/SVModalWebViewController.m b/SVWebViewController/SVModalWebViewController.m index 38cfd13..45bd26a 100644 --- a/SVWebViewController/SVModalWebViewController.m +++ b/SVWebViewController/SVModalWebViewController.m @@ -55,6 +55,7 @@ - (void)viewWillAppear:(BOOL)animated { self.webViewController.title = self.title; self.navigationBar.tintColor = self.barsTintColor; + self.navigationBar.translucent = self.barsTranslucent; } @end diff --git a/SVWebViewController/SVWebViewController.m b/SVWebViewController/SVWebViewController.m index 2714aaf..9aa4272 100644 --- a/SVWebViewController/SVWebViewController.m +++ b/SVWebViewController/SVWebViewController.m @@ -193,6 +193,7 @@ - (void)updateToolbarItems { toolbar.items = items; toolbar.barStyle = self.navigationController.navigationBar.barStyle; toolbar.tintColor = self.navigationController.navigationBar.tintColor; + toolbar.translucent = self.navigationController.navigationBar.translucent; self.navigationItem.rightBarButtonItems = items.reverseObjectEnumerator.allObjects; } @@ -211,6 +212,7 @@ - (void)updateToolbarItems { self.navigationController.toolbar.barStyle = self.navigationController.navigationBar.barStyle; self.navigationController.toolbar.tintColor = self.navigationController.navigationBar.tintColor; + self.navigationController.toolbar.translucent = self.navigationController.navigationBar.translucent; self.toolbarItems = items; } } From 12be67ed37abee559885e2f1cfaff42e46e5b345 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kawashima Date: Thu, 11 Dec 2014 21:11:42 +0900 Subject: [PATCH 2/4] Added barsStyle property to SVModlaWebViewController refs #1 --- Demo/Classes/ViewController.m | 2 ++ SVWebViewController/SVModalWebViewController.h | 1 + SVWebViewController/SVModalWebViewController.m | 1 + 3 files changed, 4 insertions(+) diff --git a/Demo/Classes/ViewController.m b/Demo/Classes/ViewController.m index 6f736cc..0d8f3d9 100644 --- a/Demo/Classes/ViewController.m +++ b/Demo/Classes/ViewController.m @@ -24,7 +24,9 @@ - (void)presentWebViewController { NSURL *URL = [NSURL URLWithString:@"http://samvermette.com"]; SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithURL:URL]; webViewController.modalPresentationStyle = UIModalPresentationPageSheet; + webViewController.barsTintColor = [UIColor whiteColor]; webViewController.barsTranslucent = NO; + webViewController.barsStyle = UIBarStyleBlack; [self presentViewController:webViewController animated:YES completion:NULL]; } diff --git a/SVWebViewController/SVModalWebViewController.h b/SVWebViewController/SVModalWebViewController.h index 53f0f5d..516d98f 100644 --- a/SVWebViewController/SVModalWebViewController.h +++ b/SVWebViewController/SVModalWebViewController.h @@ -16,5 +16,6 @@ @property (nonatomic, strong) UIColor *barsTintColor; @property (nonatomic, assign, getter=isBarsTranslucent) BOOL barsTranslucent; +@property (nonatomic, assign) UIBarStyle barsStyle; @end diff --git a/SVWebViewController/SVModalWebViewController.m b/SVWebViewController/SVModalWebViewController.m index 45bd26a..8f398d1 100644 --- a/SVWebViewController/SVModalWebViewController.m +++ b/SVWebViewController/SVModalWebViewController.m @@ -56,6 +56,7 @@ - (void)viewWillAppear:(BOOL)animated { self.webViewController.title = self.title; self.navigationBar.tintColor = self.barsTintColor; self.navigationBar.translucent = self.barsTranslucent; + self.navigationBar.barStyle = self.barsStyle; } @end From 3cc5fd7fe37654a4b41bbc0943393a1f1ac51507 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kawashima Date: Thu, 25 Dec 2014 13:04:30 +0900 Subject: [PATCH 3/4] iOS8 can set property barsTintColor Maybe iOS8 quickly show web view controller before call viewWillAppear, so set property immediately. fixes #118 --- SVWebViewController/SVModalWebViewController.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SVWebViewController/SVModalWebViewController.m b/SVWebViewController/SVModalWebViewController.m index 8f398d1..1ed37fe 100644 --- a/SVWebViewController/SVModalWebViewController.m +++ b/SVWebViewController/SVModalWebViewController.m @@ -54,9 +54,12 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:NO]; self.webViewController.title = self.title; - self.navigationBar.tintColor = self.barsTintColor; self.navigationBar.translucent = self.barsTranslucent; self.navigationBar.barStyle = self.barsStyle; } +- (void)setBarsTintColor:(UIColor *)barsTintColor { + self.navigationBar.tintColor = barsTintColor; +} + @end From 63ea5357e37e600153b494d40d1ed117db8a724a Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kawashima Date: Tue, 6 Jan 2015 14:11:45 +0900 Subject: [PATCH 4/4] Can change toolbar hidden fixes #2 --- Demo/Classes/ViewController.m | 1 + SVWebViewController/SVModalWebViewController.h | 1 + SVWebViewController/SVModalWebViewController.m | 5 +++++ SVWebViewController/SVWebViewController.h | 2 ++ SVWebViewController/SVWebViewController.m | 2 +- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Demo/Classes/ViewController.m b/Demo/Classes/ViewController.m index 0d8f3d9..7097b76 100644 --- a/Demo/Classes/ViewController.m +++ b/Demo/Classes/ViewController.m @@ -27,6 +27,7 @@ - (void)presentWebViewController { webViewController.barsTintColor = [UIColor whiteColor]; webViewController.barsTranslucent = NO; webViewController.barsStyle = UIBarStyleBlack; + webViewController.toolBarHidden = YES; [self presentViewController:webViewController animated:YES completion:NULL]; } diff --git a/SVWebViewController/SVModalWebViewController.h b/SVWebViewController/SVModalWebViewController.h index 516d98f..0fb098f 100644 --- a/SVWebViewController/SVModalWebViewController.h +++ b/SVWebViewController/SVModalWebViewController.h @@ -17,5 +17,6 @@ @property (nonatomic, strong) UIColor *barsTintColor; @property (nonatomic, assign, getter=isBarsTranslucent) BOOL barsTranslucent; @property (nonatomic, assign) UIBarStyle barsStyle; +@property (nonatomic, assign, getter=toolBarHidden) BOOL toolBarHidden; @end diff --git a/SVWebViewController/SVModalWebViewController.m b/SVWebViewController/SVModalWebViewController.m index 1ed37fe..dbf4aed 100644 --- a/SVWebViewController/SVModalWebViewController.m +++ b/SVWebViewController/SVModalWebViewController.m @@ -62,4 +62,9 @@ - (void)setBarsTintColor:(UIColor *)barsTintColor { self.navigationBar.tintColor = barsTintColor; } +- (void)setToolBarHidden:(BOOL)toolBarHidden +{ + self.webViewController.toolBarHidden = toolBarHidden; +} + @end diff --git a/SVWebViewController/SVWebViewController.h b/SVWebViewController/SVWebViewController.h index ccd90bf..23219a1 100644 --- a/SVWebViewController/SVWebViewController.h +++ b/SVWebViewController/SVWebViewController.h @@ -12,4 +12,6 @@ - (instancetype)initWithURL:(NSURL*)URL; - (instancetype)initWithURLRequest:(NSURLRequest *)request; +@property (nonatomic, assign, getter=toolBarHidden) BOOL toolBarHidden; + @end diff --git a/SVWebViewController/SVWebViewController.m b/SVWebViewController/SVWebViewController.m index 9aa4272..a0f6183 100644 --- a/SVWebViewController/SVWebViewController.m +++ b/SVWebViewController/SVWebViewController.m @@ -82,7 +82,7 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { - [self.navigationController setToolbarHidden:NO animated:animated]; + [self.navigationController setToolbarHidden:self.toolBarHidden animated:animated]; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [self.navigationController setToolbarHidden:YES animated:animated];