Skip to content

Commit

Permalink
also show fingertips when capturing screen
Browse files Browse the repository at this point in the history
On iOS 11 and higher it's possible to record the screen on the device itself. Making touches visible in that scenario is also very useful.
  • Loading branch information
koenpunt committed Aug 15, 2019
1 parent cdffaba commit aa6453c
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions MBFingerTipWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,23 @@ - (void)MBFingerTipWindow_commonInit
name:UIScreenDidDisconnectNotification
object:nil];

if (@available(iOS 11.0, *))
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(screenCaptureChanged:)
name:UIScreenCapturedDidChangeNotification
object:nil];

// Set up active now, in case the screen was present before the window was created (or application launched).
//
[self updateFingertipsAreActive];
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIScreenDidDisconnectNotification object:nil];
if (@available(iOS 11.0, *))
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIScreenCapturedDidChangeNotification object:nil];
}

#pragma mark -
Expand Down Expand Up @@ -156,12 +164,12 @@ - (UIImage *)touchImage

- (void)setAlwaysShowTouches:(BOOL)flag
{
if (_alwaysShowTouches != flag)
{
_alwaysShowTouches = flag;
if (_alwaysShowTouches != flag)
{
_alwaysShowTouches = flag;

[self updateFingertipsAreActive];
}
}
}

#pragma mark -
Expand All @@ -177,6 +185,11 @@ - (void)screenDisconnect:(NSNotification *)notification
[self updateFingertipsAreActive];
}

- (void)screenCaptureChanged:(NSNotification *)notification
{
[self updateFingertipsAreActive];
}

- (BOOL)anyScreenIsMirrored
{
if ( ! [UIScreen instancesRespondToSelector:@selector(mirroredScreen)])
Expand All @@ -186,6 +199,10 @@ - (BOOL)anyScreenIsMirrored
{
if ([screen mirroredScreen] != nil)
return YES;

if (@available(iOS 11.0, *))
if ([screen isCaptured])
return YES;
}

return NO;
Expand Down

0 comments on commit aa6453c

Please sign in to comment.