2017-07-28 9 views
2

私のアプリでオフスクリーンレンダリングされているビューを見たいと思っています。私はiOSシミュレータの「カラーオフスクリーンレンダリング」機能を使用して、オフスクリーンレンダリングビューを黄色で表示できます。しかし、画面は黄色で表示され、私はそれを信じていません。iOSシミュレータの「カラーオフスクリーンレンダリング」機能に問題がありますか?

その後、私の好きな私のテストコードを試してみてください。「UITabBarController」、「UINavigationController」と「のUIViewController」:あなたが上見ることができるように

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 
    self.window.backgroundColor = [UIColor whiteColor]; 

    self.window.rootViewController = [[UITabBarController alloc] init]; 
    // self.window.rootViewController = [[UINavigationController alloc] init]; 
    // self.window.rootViewController = [[UIViewController alloc] init]; 

    [self.window makeKeyWindow]; 
} 

、私は単純にorginalコントローラによって異なるウィンドウのrootViewController 3回に設定します。

'UIViewController'のみが画面全体に色付けされていません!

enter image description here

orginal rootViewControllerとUINavigationControllerは、オフスクリーンレンダリング画面全体を発生しますだから、なぜ誰もが知っている??????

答えて

1

デフォルトのtranslucentの値がUITabBarUINavigationBarの場合はYESです。

詳細については、AppleドキュメントのUINavigationBar.translucentおよびUITabBar.translucentをご確認ください。 translucentYESNOとき

赤い背景ルート・ビュー・コントローラとUINavigationControllerを作成することで小さなデモは、我々は違いを比較することができます。デフォルトでは

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 
    self.window.backgroundColor = [UIColor whiteColor]; 

    UIViewController* viewController = [[UIViewController alloc] init]; 
    viewController.view.backgroundColor = [UIColor redColor]; 
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController]; 
// nav.navigationBar.translucent = NO; 
    self.window.rootViewController = nav; 

    [self.window makeKeyWindow]; 
    return YES; 
} 

、半透明でYESです。だから、UINavigationBarの背景が少し赤いことがわかります。

enter image description here

色オフスクリーンレンダリング

enter image description here

しかし、我々はNOに半透明の設定。 UINavigationBarのバックグラウンドでもう赤色ではありません。

enter image description here

レンダリングされたオフスクリーン・色

enter image description here


画面が着色されている理由ですので、ここでは透明を持っています。 translucentUITabBarの同様のことを試すことができます。

UINavigationControllerUITabBarControllerでオフスクリーンレンダリングを避けるには、このプロパティをNOに設定する必要があります。

関連する問題