当应用程序第一次启动并为此使用时,我正在制作一个教程UIPageViewController
。一切正常,但背景颜色UIPageViewController
没有变得透明。一直是黑色的,如下图:
这是我添加的方式UIPageViewController
(在标签栏控制器中)
.h 文件:
@interface CHMainTabViewController : UITabBarController <UIPageViewControllerDataSource>
@property (strong, nonatomic) UIPageViewController *pageViewController;
@end
.m 文件(在 中viewDidLoad
):
// Create page view controller
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;
self.pageViewController.view.backgroundColor = [UIColor clearColor];
TutorialViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self presentViewController:_pageViewController animated:YES completion:nil];
在我的 AppDelegate.m 中,我还设置UIPageControl
了清除背景颜色:
UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor clearColor];
[pageControl setOpaque:NO];
self.window.backgroundColor = [UIColor clearColor];
我知道问题在于UIPageViewController
的背景颜色。不能将控制器的背景设置为透明吗?
请帮忙!
谢谢。