react-native-fast-orientation-locker
v0.9.0
Published
Support for orientation
Readme
react-native-fast-orientation-locker
Support for orientation
Installation
npm install react-native-fast-orientation-lockerGoto your AppDelegate.swift and add FastOrientationLocker & application function
import FastOrientationLocker //<--- add this code
...
//<--- add more this function --->
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return FastOrientationLockerImpl.supportedInterfaceOrientations()
}
Usage
import {
SafeAreaView,
StyleSheet,
Text,
TouchableOpacity
} from 'react-native';
import {
lockToLandscape,
lockToPortrait,
unlockAllOrientations,
} from 'react-native-fast-orientation-locker';
export default function App() {
return (
<SafeAreaView style={styles.container}>
<TouchableOpacity
onPress={() => {
lockToLandscape();
}}
>
<Text>lockToLandscape</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
lockToPortrait();
}}
>
<Text>lockToPortrait</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
unlockAllOrientations();
}}
>
<Text>unlockAllOrientations</Text>
</TouchableOpacity>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
