ealeksandrov / EAIntroView

Highly customizable drop-in solution for introduction views.
MIT License
3.76k stars 501 forks source link

Full Screen IntroView #192

Closed Mehrdadmaskull closed 7 years ago

Mehrdadmaskull commented 7 years ago

Since the latest update, I can't seem to make the EAIntroView to show and take up the whole view. Using showFullScreen which uses the window, makes the skip button and the pageController go a little off-screen. I'm trying to show it on top of a navigationController. Using showInView:self.navigationController.view or self.view doesn't work either and it makes the intro leave a small bar under it.

sharedWindow.rootViewController.view.bounds:

simulator screen shot nov 6 2016 2 51 48 pm

self.view.bounds:

simulator screen shot nov 6 2016 2 50 31 pm

ealeksandrov commented 7 years ago

Can you reproduce your setup in demo project? We also have navigation controller there.

Mehrdadmaskull commented 7 years ago

Sure, here's some code:

UIView *introContainer = [[UIView alloc]initWithFrame:self.view.bounds];

UIImage *introImage = [UIImage imageNamed:@"main2"];

UIImageView *introImageView = [[UIImageView alloc]initWithFrame:CGRectMake((screenSize.width - introImage.size.width)/2, 80, introImage.size.width, introImage.size.height)];

UILabel *introLabel = [[UILabel alloc]init];

introLabel.numberOfLines = 0; 

introLabel.text = @"Welcome!";

introLabel.textColor = [UIColor whiteColor];

introLabel.frame = CGRectMake(0, introImageView.frame.size.height+introImageView.frame.origin.y, screenSize.width - 50, 100);

introLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:20];

introLabel.textAlignment = NSTextAlignmentCenter;

CGPoint p = CGPointMake(self.view.center.x, introLabel.center.y);

introLabel.center = p;

UISwitch *dontshowSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(10, 30, 30, 30)];

[dontshowSwitch addTarget: self action: @selector(flip:) forControlEvents: UIControlEventValueChanged];

UILabel *dontshowLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, 30, 200, 30)];
dontshowLabel.text = @"Don't show on start again";
dontshowLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:13];
dontshowLabel.textColor = [UIColor whiteColor];

[introContainer addSubview:dontshowLabel];
[introContainer addSubview:dontshowSwitch];
[introContainer addSubview:introImageView];
[introContainer addSubview:introLabel];

EAIntroPage *page0 = [EAIntroPage pageWithCustomView:introContainer];

//PAGE1
EAIntroPage *page1 = [EAIntroPage page];
page1.title = @"What's new in Version 2.0";
page1.titleFont = [UIFont fontWithName:@"Avenir-Medium" size:20];
page1.titlePositionY = 200;

UIWindow *sharedWindow = UIApplication.sharedApplication.keyWindow;

//EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.view.bounds andPages:@[page0]];
EAIntroView *intro = [[EAIntroView alloc] initWithFrame:sharedWindow.rootViewController.view.bounds andPages:@[page0]];
intro.bgImage = [UIImage imageNamed:@"b"];
intro.pageControlY = 20;
self.navigationController.navigationBarHidden = YES;
intro.delegate = self;

//[intro showInView:self.view];
[intro showFullscreen];
ealeksandrov commented 7 years ago

That's not problem with IntroView frame on your first screenshot. intro.pageControlY = 20; is the source of issue.

You can see here that property called pageControlY - not pageControlBottomPadding. So 20 will be the length from page control top to intro view bottom.

In #190 we fixed autolayout calculations with default frames, so page control Y (20) - default height (36) = -16 padding to bottom. That's why it is displayed below bottom border. Skip button don't have Y setup, so it used the same alignment as page control.

Previous version layout calculation was wrong. Please adjust your pageControlY to bigger value to fix.