2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift2.0 ナビゲーションバー 透過無効

Last updated at Posted at 2015-11-11

スクロールした時とかに曇りガラスにしたくない時に使う方法

通常何もしなければ、ナビゲーションバーの下にあるものは、曇りガラスが適用されてボケて見える。
Simulator Screen Shot 2015.11.11 17.42.13.png

上記のコード、1行入れるとボケにくくなる。
Simulator Screen Shot 2015.11.11 15.39.17.png

AppDelegate.swift
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    internal var window: UIWindow?
    private var navigationController: UINavigationController!


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let viewController: ViewController = ViewController()
        navigationController = UINavigationController(rootViewController: viewController)
        self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
        // 下記の1行を追加する
        self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
//        self.navigationController?.navigationBar.translucent = false
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
        self.window!.rootViewController = navigationController
        self.window!.backgroundColor = UIColor.whiteColor()
        self.window!.makeKeyAndVisible()
        return true
    }

    func applicationWillResignActive(application: UIApplication) {}
    func applicationDidEnterBackground(application: UIApplication) {}
    func applicationWillEnterForeground(application: UIApplication) {}
    func applicationDidBecomeActive(application: UIApplication) {}
    func applicationWillTerminate(application: UIApplication) {}
}
2
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?