4
4

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.

SwiftでStatusBarのみ色変えたい場合

Posted at

一般的にはUINavigationBarの色を変えて、ステータスバー透過とかでナビゲーションバーの色とステータスバーの色が同じに出来たかと思いますが、ステータスバーの色だけ変えたいという場合もあるかと思います。

そんな場合は、viewDidLoadの中とかで、UIView作成してステータスバー上に乗せてしまえば良いようです。


let statusBarBackground = UIView(frame: CGRectMake(0 , 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(UIApplication.sharedApplication().statusBarFrame)))
statusBarBackground.backgroundColor = UIColor.redColor()
self.view.addSubview(statusBarBackground)

4
4
0

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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?