Home键指示器隐藏相关API
@interface UIViewController (UIHomeIndicatorAutoHidden)
// Override to return a child view controller or nil. If non-nil, that view controller's home indicator auto-hiding will be used. If nil, self is used. Whenever the return value changes, -setNeedsHomeIndicatorAutoHiddenUpdate should be called.
- (nullable UIViewController *)childViewControllerForHomeIndicatorAutoHidden API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos);
// Controls the application's preferred home indicator auto-hiding when this view controller is shown.
- (BOOL)prefersHomeIndicatorAutoHidden API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos);
// This should be called whenever the return values for the view controller's home indicator auto-hiding have changed.
- (void)setNeedsUpdateOfHomeIndicatorAutoHidden API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, tvos);
@end
打开自动隐藏功能
- (BOOL)prefersHomeIndicatorAutoHidden {
return YES;
}
如果想手动控制隐藏功能,动态返回一个值,并且在更新的时候调用 setNeedsUpdateOfHomeIndicatorAutoHidden 方法
- (BOOL)prefersHomeIndicatorAutoHidden {
return _isHomeIndicatorHidden;
}
// 更新值时调用
_isHomeIndicatorHidden = NO;
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
*注:调用方法隐藏时,Home条会在1~2秒后自动慢慢消失