Hello, I want to write extension for iOS for hiding home indicator on iPhoneX.
It requires overriding prefersHomeIndicatorAutoHidden
getter of UIViewController
.
Here is full obj-c code:
How can I repeat that logic in lime extension?
Thanks!
There’s logic in this video about adding functionality to UIViewController without overriding the class manually
…we should write it down
Thanks Joshua! I’ll watch this video later.
We implemented functionality for hiding home indicator that way:
- We created 2 files:
UIViewController+UIViewController_HideHomeIndicator.h
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIViewController (UIViewController_HideHomeIndicator)
- (BOOL)prefersHomeIndicatorAutoHidden;
@end
NS_ASSUME_NONNULL_END
UIViewController+UIViewController_HideHomeIndicator.mm
#import "UIViewController+UIViewController_HideHomeIndicator.h"
@implementation UIViewController (UIViewController_HideHomeIndicator)
- (BOOL)prefersHomeIndicatorAutoHidden {
return YES;
}
@end
-
Add them as templates for copying to
Classes
folder for iOS. -
Add these files to your XCode project and copy back
*.pbxproj
file from XCode (it adds new files to list). Add new pbxproj astemplate
to project. -
Profit!
But home indicator always appears after touching device screen and dissapears after few seconds.
Maybe this approach will be usefull for someone
Is the “+” in the filename a special behavior in iOS development?
As far as I know it doesn’t have any special behaviors. It was named just according to name convention for categories.