LoginSignup
2
2

More than 5 years have passed since last update.

ReactNativeのエラー画面の色を変える

Last updated at Posted at 2018-02-18

ReactNativeのエラー画面の色を変える小ネタです。

変えるといってもライブラリを導入するとかではなくて、ReactNativeのソースをいじる感じです。

react-native initをすると、node_modules/react-native/React/Modules/配下にRCTRedbox.mというファイルができると思います。

このファイルがエラー画面のスタイルを設定してるコードです。

なのでここにあるスタイル定義部分の色を好きに変更すれば終わりです。

- (instancetype)initWithFrame:(CGRect)frame {
...
// 背景を白にする
self.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; 
- (UITableViewCell *)reuseCell:(UITableViewCell *)cell forErrorMessage:(NSString *)message {
...

// テキストカラーを黒にする
cell.textLabel.textColor = [UIColor blackColor];
cell.detailTextLabel.textColor = [UIColor blackColor];
- (UITableViewCell *)reuseCell:(UITableViewCell *)cell forStackFrame:(RCTJSStackFrame *)stackFrame {
...
// テキストカラーを黒にする
cell.textLabel.textColor = [UIColor blackColor];
cell.detailTextLabel.textColor = [UIColor blackColor];

これらの変更を加えてから、再度react-native run-iosとかして再起動するとエラー画面の色が変更されます。

スクリーンショット 2018-02-18 12.11.31.png

小ネタでした。

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