Skip to content

Commit

Permalink
Enforce no autoresizing mask for custom view controller to prevent au…
Browse files Browse the repository at this point in the history
…tolayout issues with manual layout custom bar controller views

Fixes #560
  • Loading branch information
LeoNatan committed Feb 16, 2024
1 parent 39bf579 commit 7b3747a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions LNPopupController/LNPopupController/Private/LNPopupBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ - (void)_layoutCustomBarController
return;
}

_customBarViewController.view.autoresizingMask = UIViewAutoresizingNone;

CGRect frame = _contentView.bounds;
frame.size.height = _customBarViewController.preferredContentSize.height;
_customBarViewController.view.frame = frame;
Expand Down Expand Up @@ -650,10 +652,6 @@ - (void)layoutSubviews

[_contentView.contentView insertSubview:_imageView aboveSubview:_toolbar];
[_contentView.contentView insertSubview:_titlesView aboveSubview:_imageView];
if(_customBarViewController != nil)
{
[_contentView.contentView insertSubview:_customBarViewController.view aboveSubview:_bottomShadowView];
}

UIScreen* screen = self.window.screen ?: UIScreen.mainScreen;
CGFloat h = 1 / screen.scale;
Expand Down Expand Up @@ -691,7 +689,7 @@ - (void)layoutSubviews

[self _layoutTitles];

CGFloat titleSpacing = 1 + (1 / MAX(1, self.window.screen.scale));
CGFloat titleSpacing = 1 + (1 / MAX(1, screen.scale));
if(_resolvedStyle == LNPopupBarStyleCompact)
{
titleSpacing = 0;
Expand Down Expand Up @@ -1821,7 +1819,7 @@ - (void)setCustomBarViewController:(LNPopupCustomBarViewController*)customBarVie

[_customBarViewController _activeAppearanceDidChange:self.activeAppearance];

[self.contentView addSubview:_customBarViewController.view];
[_contentView.contentView insertSubview:_customBarViewController.view aboveSubview:_bottomShadowView];

if(_customBarViewController.view.translatesAutoresizingMaskIntoConstraints == NO)
{
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let package = Package(
cSettings: [
.headerSearchPath("."),
.headerSearchPath("Private"),
.unsafeFlags(["-w"])
]),
.target(
name: "LNPopupController",
Expand Down

0 comments on commit 7b3747a

Please sign in to comment.