21
21

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.

フラットなナビゲーションバー

Posted at

下部の影がどうしても消せなくて、これが正解なのか分からないけど、なんとかできた。

事前にprefixファイルに下記を追記しています

***-Prefix.pch
#define RGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]

設定はこちら

AppDelegate.m

// ナビゲーションバーのテキストカラーを設定
[UINavigationBar appearance].titleTextAttributes = @{NSForegroundColorAttributeName: RGB(255, 255, 255)};
    
// ナビゲーションバーの影を消す
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
									forBarPosition:UIBarPositionAny
									barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
    
// ナビゲーションバーの背景色を設定
[[UINavigationBar appearance] setBackgroundColor: RGB(101, 181, 23)];
    
// ステータスバーのテキストカラーを設定
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    
// ステータスバーの背景色を設定
UIView* statusBarBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
statusBarBg.backgroundColor = RGB(101, 181, 23);
[self.window.rootViewController.view addSubview:statusBarBg];

すごく無理なやり方で気持ち悪いです(汗

簡単な方法をご存知でしたらおしえてください!

21
21
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?