Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 11 and iPhone X #9

Open
iDevelopper opened this issue Nov 2, 2017 · 1 comment
Open

iOS 11 and iPhone X #9

iDevelopper opened this issue Nov 2, 2017 · 1 comment

Comments

@iDevelopper
Copy link

Great library, thank you!

As we can't test it in the simulator, I would like to know if it respects already the safe area and particularly for the new iPhone X? If not, have you planned an update for that?

Regards,

@iDevelopper
Copy link
Author

Here is a sample of how you could update for iPhone X:

ReaderToolBar.zip

You can test it on simulator, I just added:

    // iOS 11 and iPhone X
    id toItem;
    if (@available(iOS 11.0, *)) {
        toItem = self.view.safeAreaLayoutGuide;
    }
    else {
        toItem = view;
    }
    //

And replaced toItem:view by toItem:toItem for adding constraints. For example:

    if ((upperToolbar = [[ReaderUpperToolbar alloc] initWithFrame:CGRectZero]))
    {
        [view addSubview:upperToolbar]; upperToolbar.delegate = self; // ReaderUpperToolbarDelegate
        upperToolbar.translatesAutoresizingMaskIntoConstraints = NO;
        
        NSLayoutConstraint *y = [NSLayoutConstraint constraintWithItem:upperToolbar attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual
                                                                toItem:toItem attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];
        
        [view addConstraint:y]; [upperToolbar setLayoutConstraintY:y];
        
        [view addConstraint:[NSLayoutConstraint constraintWithItem:upperToolbar attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual
                                                            toItem:toItem attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0]];
        
        [view addConstraint:[NSLayoutConstraint constraintWithItem:upperToolbar attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual
                                                            toItem:toItem attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0.0]];
    }

I am willing to make the changes throughout the project, but I am not very familiar with pull requests.

I do not have an iPhone X to test on real device, that's why I created this little example, but I think it should work for the whole project.

What about this?

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant