Skip to content

Commit

Permalink
Opaque navigation bar background for iPad
Browse files Browse the repository at this point in the history
  • Loading branch information
weiran committed Jan 3, 2016
1 parent 595cc5a commit 3a63403
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Client/Post List/NewsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NewsViewController : UITableViewController, UISplitViewControllerDelegate,

splitViewController!.delegate = self

Theme.setNavigationBarBackgroundGradient(navigationController!.navigationBar)
Theme.setNavigationBarBackground(navigationController!.navigationBar)
loadPosts()
}

Expand Down
1 change: 1 addition & 0 deletions Client/Post/CommentsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CommentsViewController : UIViewController, UITableViewDelegate, UITableVie
override func viewDidLoad() {
super.viewDidLoad()

Theme.setNavigationBarBackground(navigationController!.navigationBar)
setupPostTitleView()
tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension
Expand Down
10 changes: 9 additions & 1 deletion Client/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Theme {
static let orangeColour = UIColor(colorLiteralRed: 223/255.0, green: 111/255.0, blue: 4/255.0, alpha: 1)
static let backgroundGreyColour = UIColor(red:0.937, green:0.937, blue:0.956, alpha:1)

static func setNavigationBarBackgroundGradient(navigationBar: UINavigationBar) {
static private func setNavigationBarBackgroundGradient(navigationBar: UINavigationBar) {
var frame = navigationBar.frame
frame.size.height += 20 // include status bar

Expand All @@ -32,4 +32,12 @@ class Theme {

navigationBar.setBackgroundImage(image, forBarMetrics: UIBarMetrics.Default)
}

static func setNavigationBarBackground(navigationBar: UINavigationBar) {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
setNavigationBarBackgroundGradient(navigationBar)
} else {
navigationBar.barTintColor = purpleColour
}
}
}

0 comments on commit 3a63403

Please sign in to comment.