Skip to content

Commit 06af3c6

Browse files
committed
Now listening to a notification from UINavigationController allowing to adjust height when the UINavigationController is pushing or popping views.
1 parent c7fd53a commit 06af3c6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

CSNotificationView/CSNotificationView.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
static NSInteger const kCSNotificationViewEmptySymbolViewTag = 666;
1212

13+
static NSString* const kCSNotificationViewUINavigationControllerWillShowViewControllerNotification = @"UINavigationControllerWillShowViewControllerNotification";
14+
1315
@interface CSNotificationView ()
1416

1517
#pragma mark - blur effect
@@ -126,6 +128,11 @@ - (instancetype)initWithParentViewController:(UIViewController*)viewController
126128

127129
}
128130

131+
//Notifications
132+
{
133+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(navigationControllerWillShowViewControllerNotification:) name:kCSNotificationViewUINavigationControllerWillShowViewControllerNotification object:nil];
134+
}
135+
129136
//Content views
130137
{
131138
//textLabel
@@ -155,6 +162,26 @@ - (instancetype)initWithParentViewController:(UIViewController*)viewController
155162
return self;
156163
}
157164

165+
- (void)dealloc
166+
{
167+
[[NSNotificationCenter defaultCenter] removeObserver:self name:kCSNotificationViewUINavigationControllerWillShowViewControllerNotification object:nil];
168+
}
169+
170+
- (void)navigationControllerWillShowViewControllerNotification:(NSNotification*)note
171+
{
172+
if (self.visible && [self.parentNavigationController isEqual:note.object]) {
173+
174+
__block typeof(self) weakself = self;
175+
[UIView animateWithDuration:0.1 animations:^{
176+
CGRect endFrame;
177+
[weakself animationFramesForVisible:weakself.visible startFrame:nil endFrame:&endFrame];
178+
[weakself setFrame:endFrame];
179+
[weakself updateConstraints];
180+
}];
181+
182+
}
183+
}
184+
158185
#pragma mark - layout
159186

160187
- (void)updateConstraints

0 commit comments

Comments
 (0)