vfr / UXReader-iOS

UXReader PDF Framework for iOS
Other
290 stars 66 forks source link

iOS 11 and iPhone X #9

Open iDevelopper opened 6 years ago

iDevelopper commented 6 years ago

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 commented 6 years ago

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,