ソースを参照

Put the UINavigationController theming in a category

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Romain Goyet 12 年 前
コミット
d833073370

+ 15 - 0
AspenProject/UINavigationController+Theme.h

@@ -0,0 +1,15 @@
+//
+//  UINavigationController+Theme.h
+//  VLC for iOS
+//
+//  Created by Romain Goyet on 14/06/13.
+//  Copyright (c) 2013 Applidium. All rights reserved.
+//
+//  Refer to the COPYING file of the official project for license.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UINavigationController (Theme)
+- (void)loadTheme;
+@end

+ 23 - 0
AspenProject/UINavigationController+Theme.m

@@ -0,0 +1,23 @@
+//
+//  UINavigationController+Theme.m
+//  VLC for iOS
+//
+//  Created by Romain Goyet on 14/06/13.
+//  Copyright (c) 2013 Applidium. All rights reserved.
+//
+//  Refer to the COPYING file of the official project for license.
+//
+
+#import "UINavigationController+Theme.h"
+
+@implementation UINavigationController (Theme)
+- (void)loadTheme
+{
+    UINavigationBar *navBar = self.navigationBar;
+    [navBar setBackgroundImage:[UIImage imageNamed:@"navBarBackground"]
+                 forBarMetrics:UIBarMetricsDefault];
+    [navBar setBackgroundImage:[UIImage imageNamed:@"navBarBackgroundPhoneLandscape"]
+                 forBarMetrics:UIBarMetricsLandscapePhone];
+    navBar.barStyle = UIBarStyleBlack;
+}
+@end

+ 2 - 5
AspenProject/VLCAppDelegate.m

@@ -15,6 +15,7 @@
 #import "VLCPlaylistViewController.h"
 #import "VLCMovieViewController.h"
 #import "PAPasscodeViewController.h"
+#import "UINavigationController+Theme.h"
 
 @interface VLCAppDelegate () <PAPasscodeViewControllerDelegate, DirectoryWatcherDelegate> {
     NSURL *_tempURL;
@@ -48,11 +49,7 @@
     _playlistViewController = [[VLCPlaylistViewController alloc] init];
 
     self.navigationController = [[UINavigationController alloc] initWithRootViewController:_playlistViewController];
-    UINavigationBar *navBar = self.navigationController.navigationBar;
-    [navBar setBackgroundImage:[UIImage imageNamed:@"navBarBackground"] forBarMetrics:UIBarMetricsDefault];
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
-        [navBar setBackgroundImage:[UIImage imageNamed:@"navBarBackgroundPhoneLandscape"] forBarMetrics:UIBarMetricsLandscapePhone];
-    navBar.barStyle = UIBarStyleBlack;
+    [self.navigationController loadTheme];
 
     self.window.rootViewController = self.navigationController;
     [self.window makeKeyAndVisible];

+ 6 - 0
VLC for iOS.xcodeproj/project.pbxproj

@@ -36,6 +36,7 @@
 		2915544317490D4A00B86CAD /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2915544217490D4A00B86CAD /* Security.framework */; };
 		293DF2F417494F8200BB880F /* DropboxSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D05ADEA174945CE0087550C /* DropboxSDK.framework */; };
 		29CE2D44174912C600922D8F /* VLCHTTPUploaderController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29CE2D42174912C600922D8F /* VLCHTTPUploaderController.m */; };
+		7A50619F176E3D410036E15D /* UINavigationController+Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A50619E176E3D410036E15D /* UINavigationController+Theme.m */; };
 		7A57C1371769F0BA00807630 /* VLCMenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7A57C1361769F0BA00807630 /* VLCMenuViewController.xib */; };
 		7AC8629D1765DC560011611A /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 7AC8629B1765DC560011611A /* style.css */; };
 		7AC862A61765E9510011611A /* jquery-1.10.1.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 7AC8629E1765E90C0011611A /* jquery-1.10.1.min.js */; };
@@ -323,6 +324,8 @@
 		2915544217490D4A00B86CAD /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
 		29CE2D41174912C600922D8F /* VLCHTTPUploaderController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCHTTPUploaderController.h; sourceTree = "<group>"; };
 		29CE2D42174912C600922D8F /* VLCHTTPUploaderController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCHTTPUploaderController.m; sourceTree = "<group>"; };
+		7A50619D176E3D410036E15D /* UINavigationController+Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+Theme.h"; sourceTree = "<group>"; };
+		7A50619E176E3D410036E15D /* UINavigationController+Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+Theme.m"; sourceTree = "<group>"; };
 		7A57C1361769F0BA00807630 /* VLCMenuViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = VLCMenuViewController.xib; path = Resources/VLCMenuViewController.xib; sourceTree = SOURCE_ROOT; };
 		7AC8629B1765DC560011611A /* style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = style.css; sourceTree = "<group>"; };
 		7AC8629E1765E90C0011611A /* jquery-1.10.1.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "jquery-1.10.1.min.js"; sourceTree = "<group>"; };
@@ -922,6 +925,8 @@
 				7D31CF081746AF09005997E0 /* VLCStatusLabel.m */,
 				7D47D72D1761101700E86BAD /* VLCSlider.h */,
 				7D47D72E1761101700E86BAD /* VLCSlider.m */,
+				7A50619D176E3D410036E15D /* UINavigationController+Theme.h */,
+				7A50619E176E3D410036E15D /* UINavigationController+Theme.m */,
 			);
 			name = "UI Elements";
 			sourceTree = "<group>";
@@ -1652,6 +1657,7 @@
 				7D47D72F1761101700E86BAD /* VLCSlider.m in Sources */,
 				7D2339AF176DE72E008D223C /* VLCOpenNetworkStreamViewController.m in Sources */,
 				7DB43835176E20CC00F460EE /* VLCHTTPDownloadViewController.m in Sources */,
+				7A50619F176E3D410036E15D /* UINavigationController+Theme.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};