2017-07-14 56 views
2

我想在我的文本周围放一个边框。反应vr边界不起作用

<View style={{ borderRadius: 1, borderWidth: 1, borderColor:'#FF0000',}}> 
      <Text style={{ 
       fontSize: 0.8, 
       fontWeight: '400', 
       layoutOrigin: [0.5, 0.5], 
       paddingLeft: 0.2, 
       paddingRight: 0.2, 
       textAlign: 'center', 
       textAlignVertical: 'center', 
       transform: [{translate: [0, 0, -3]}], 
      }}> 
       hello 
      </Text> 
      </View> 

如果我将borderWidth作为1,我会看到hello但看不到边框。如果我将borderWidth更改为10,我什么都看不到。我如何在hello文本中添加边框?

+0

你可以请创建一个jsFiddle吗? –

+0

我不知道如何把它放在jsFiddle,但继承人的git链接https://github.com/lunzhang/react-vr-tetris。您只需将src/index.vr.js中的代码替换为我发布的代码 –

+0

不幸的是,无法在任何流行的操场(codepen,jsbin等)中嵌入React VR代码,有人应该对开发人员进行bug在Github上关于这个:) – Valentin

回答

1

边框确实在工作,但是您的视图默认位于相机视图所在场景的中心。你真正想要做的就是在你的根视图上设置layoutOrigin,并在翻译中设置所有组件在那里正确渲染。

这应做到:

<View style={{ 
    borderRadius: 1, 
    borderWidth: 1, 
    borderColor:'#FF0000', 
    transform: [{translate: [0, 0, -3]}], 
    layoutOrigin: [0.5, 0.5], 
}}> 
    <Text style={{ 
     fontSize: 0.8, 
     fontWeight: '400', 
     paddingLeft: 0.2, 
     paddingRight: 0.2, 
     textAlign: 'center', 
     textAlignVertical: 'center', 
    }}>hello</Text> 
</View> 

这应该正确地显示在你的文字边框,虽然你会发现边框的宽度过大,因为单位不意味着像素,但是米3D世界。