Open iDevelopper opened 6 years ago
Here is a sample of how you could update for iPhone X:
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,
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,