diff --git a/App/Browser View/BrowserViewController.swift b/App/Browser View/BrowserViewController.swift index da825fc..ec89990 100644 --- a/App/Browser View/BrowserViewController.swift +++ b/App/Browser View/BrowserViewController.swift @@ -154,7 +154,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, } private func updateTitleAndURL(forWebView webView: WKWebView) { - browserView.titlebarView.titleLabelView.text = webView.title + browserView.titlebarView.setTitle(webView.title ?? "") if let urlString = webView.url?.absoluteString { toolbarController.urlBar.textField.text = urlString diff --git a/App/Titlebar and URL Bar/TitlebarView.swift b/App/Titlebar and URL Bar/TitlebarView.swift index 3bec5f8..10eec43 100644 --- a/App/Titlebar and URL Bar/TitlebarView.swift +++ b/App/Titlebar and URL Bar/TitlebarView.swift @@ -9,7 +9,7 @@ import UIKit class TitlebarView: UIView { - public let titleLabelView = UILabel(frame: .zero) + private let titleLabelView = UILabel(frame: .zero) private let backgroundImageView = UIImageView(frame: .zero) convenience init() { @@ -25,6 +25,29 @@ class TitlebarView: UIView backgroundImageView.alpha = 0.98 } + + func setTitle(_ title: String) { + let titleAttributes: [NSAttributedString.Key : Any] = [ + .font : UIFont.boldSystemFont(ofSize: 12.0), + .foregroundColor : UIColor.white + ] + + let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String + let appNameAttributes: [NSAttributedString.Key : Any] = [ + .font : UIFont.systemFont(ofSize: 12.0), + .foregroundColor : UIColor(white: 1.0, alpha: 0.75) + ] + + if title.count > 0 { + let attributedString = NSMutableAttributedString(string: title, attributes: titleAttributes) + let appAttributedString = NSAttributedString(string: " :: \(appName)", attributes: appNameAttributes) + attributedString.append(appAttributedString) + + titleLabelView.attributedText = attributedString + } else { + titleLabelView.attributedText = NSAttributedString(string: appName, attributes: titleAttributes) + } + } private func backgroundImageForSize(_ size: CGSize) -> UIImage? { var image: UIImage? = nil diff --git a/SBrowser.xcodeproj/xcshareddata/xcschemes/App.xcscheme b/SBrowser.xcodeproj/xcshareddata/xcschemes/App.xcscheme new file mode 100644 index 0000000..0c8e344 --- /dev/null +++ b/SBrowser.xcodeproj/xcshareddata/xcschemes/App.xcscheme @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +