我對UIPageViewControllers比較新,並且剛剛爲我的應用程序的「演練」實現了它。UIPageViewController在我的UIImage的底部創建邊框以及如何擺脫它
問題是,我顯示的每個圖像在底部和邊上都有一個邊框,並且因此,圖像不會顯示爲全屏,並且會看起來相連。
我在這裏附上一些圖片的這個參考:
我只是希望擺脫這種邊界和只是有pageIndicators
覆蓋全屏圖像在背景中。另外,當滑動到下一個屏幕時,我不需要圖像之間的黑色邊框(按照第二個屏幕截圖)。
這是一些代碼。我已創建一個WalkthroughViewController
文件,其中包含對圖像的引用:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor clearColor]];
CGRect insetFrame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
_imageView = [[UIImageView alloc] initWithFrame:insetFrame];
_imageView.backgroundColor = [UIColor clearColor];
[_imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[_imageView setImage:[UIImage imageNamed:_model.imageName]];
[[self view] addSubview:_imageView];
}
在我PageViewController's
viewDidLoad
,我有:
- (void)viewDidLoad
{
[super viewDidLoad];
[[self view] setBackgroundColor:[UIColor blackColor]];
_modelArray = [NSMutableArray arrayWithObjects:[[ImageModel alloc] initWithImageName:@"TimelineTut.png"],
[[ImageModel alloc] initWithImageName:@"Tut 1.png"],
[[ImageModel alloc] initWithImageName:@"Tut 2.png"],
[[ImageModel alloc] initWithImageName:@"newtut3.png"],
[[ImageModel alloc] initWithImageName:@"tut 4.png"],
nil];
_pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:50.0f] forKey:UIPageViewControllerOptionInterPageSpacingKey]];
_pageViewController.delegate = self;
_pageViewController.dataSource = self;
WalkthroughViewController *imageViewController = [[WalkthroughViewController alloc] init];
imageViewController.model = [_modelArray objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:imageViewController];
[self.pageViewController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[_pageViewController didMoveToParentViewController:self];
//CGRect pageViewRect = self.view.bounds;
// pageViewRect = CGRectInset(pageViewRect, 0.0, 0.0);
//self.pageViewController.view.frame = pageViewRect;
}
最後三個以上行被註釋掉了,但如果我取消他們離開的價值觀,它保持不變。但是,如果我將0.0更改爲40.0之類的東西,那麼可以理解的是看起來很長。
我已經嘗試設置ImageRatio
到AspectFill
,Fit
,ScaleToFill
等在WalkthroughViewController
,但沒有擺脫國界的。
視圖控制器完全在代碼中創建,而不是在故事板中,它幾乎看起來像這個問題(Putting a bar on the bottom of the UIPageViewController),但我不想要邊框,我不認爲我嵌入在容器中?
UPDATE:
通過在該行的代碼在這裏改變值:
_pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:50.0f] forKey:UIPageViewControllerOptionInterPageSpacingKey]];
50-0,我已經擺脫了對圖像的一側的空間。然而底部的保證金仍然存在。
如何擺脫黑色邊框,但保留pageViewIndicators作爲覆蓋圖像,因此使圖像全屏幕,而不是因爲邊界被壓扁?
對此的任何指導將非常感激。