React-native – Allows the touch area of ​​the button in React Native to extend to the status bar (iOS)

I have a back button in the upper left corner of my screen (using TouchableOpacity). I want to allow its hit area to extend to the status bar because this is what other apps seem to do, and it’s easy Accidentally touching the button a bit too high and touching the upper status bar makes the application feel unresponsive.

The area where I have it extends behind the status bar, but the status bar still seems to catch the touch Event. Is there a way to make it not do this (at least on the left hand side, I still like the “touch to the top” thing, which works when you touch it elsewhere)?

UINavigationBar is a UIWindow (not UIView), it is located on top of the UIWindow you are operating. Therefore , UIViews cannot be rendered from UIWindow.

What you can do is to add a transparent UIBarButtonItem to the button to trigger the same action:

 var button = UIBarButtonItem(title: "", style: .Plain, target: action: #selector(yourAction(_:)))
button.tintColor = UIColor.clear
navigationController?.navigationItem.leftBarButtonItem = button

I have a back button in the upper left corner of my screen (using TouchableOpacity). I want to allow its hit area to extend to the status bar because this is what other apps seem to do It’s easy to accidentally touch the button a bit too high and touch the upper status bar to make the application feel unresponsive.

I have its area extending behind the status bar, but the status The bar still seems to catch touch events. Is there a way to make it not (at least on the left hand side, I still like the “touch to the top” thing, which works when you touch it elsewhere)?

UINavigationBar is a UIWindow (not UIView), which is located above the UIWindow you are operating. Therefore, UIViews cannot be rendered from the UIWindow.

What you can do is to add another transparent UIBarButtonItem to the button to trigger the same action:

var button = UIBarButtonItem(title: "", style: .Plain, target: action: #selector(yourAction(_:)))
button.tintColor = UIColor.clear
navigationController?.navigationItem.leftBarButtonItem = button

Leave a Comment

Your email address will not be published.