菜鸟教程小白 发表于 2022-12-13 00:14:36

ios - UIDocumentInteractionController 导航栏颜色


                                            <p><p>在我的 iOS 应用程序中,我使用 DocumentInteractionController 来预览 .csv 文档。</p>

<pre><code>    self.documentController = ;
    ;
    ;
</code></pre>

<p>但是,我发现导航栏是完全透明的。后退按钮是白色的,因此由于白色背景,它是不可见的。</p>

<p> <img src="/image/XpO0A.png" width="320"/> </p>

<p>请注意,我在 AppDelegate 中设置了导航栏的样式:</p>

<pre><code>[ setBarTintColor:];
[ setTintColor:];
[ setTitleTextAttributes:@{NSFontAttributeName:}];
[ setBackgroundImage:[ init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[ setShadowImage:];
[ setSelectedImageTintColor:];
[ setTintColor:];
[ setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
</code></pre>

<p>本质上,我的问题是如何使 DocumentInteractionController View Controller 中导航栏的外观与整个应用程序中导航栏的外观保持一致(或至少可见!)。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这一行将透明(或者更确切地说是空的)背景图像放置到您的 UINavigationBar。这是为什么呢?</p>

<pre><code>[ setBackgroundImage:[ init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
</code></pre>

<p>只需删除该行,一切正常。</p>

<p>如果你想设置阴影图像,那么你应该考虑使用 <code>appearanceWhenContainedIn:</code> 而不是 <code>appearance</code> 这样它就不会传播到未处理的 Controller 。</p >

<p>对于状态栏样式,最简单的方法是传递 <code>self.navigationController</code> 作为演示者,而不是 self:</p>

<pre><code>- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self.navigationController;
}
</code></pre>

<p>希望这会有所帮助,</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - UIDocumentInteractionController 导航栏颜色,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/25083859/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/25083859/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - UIDocumentInteractionController 导航栏颜色