navalsaini
navalsaini

Reputation: 522

Programatically turn screen upside-down in react-native

I am building a two player game.

When player A makes a turn, the screen should turn upside down for player seated on the opposite side.

I tried using transform on a View, but think that only works on text.

So I am looking for a solution to either

a. Keep the device orientation, but turn it upside down by 180 degrees.

b. Rotate the root view on my app by 180 degrees

I would appreciate suggestions.

Upvotes: 0

Views: 1872

Answers (1)

navalsaini
navalsaini

Reputation: 522

Correction - turning the view using transform worked for me.

It was merely not working when in storyboard mode (not sure why).

Below works!

const rotateView = {
  flex: 1,
  transform: [{
    rotate: '-180deg'
  }],
}

View is rotated by 180 degrees.

Upvotes: 3

Related Questions