gpt4 book ai didi

ios - react native :Strange Behaviour backgroundColor in ListView running in iphone6Plus

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:06:00 27 4
gpt4 key购买 nike

我在使用 React Native 的 ListView 时遇到了一些问题,奇怪的是设置行的背景颜色会在 iPhone6 和 iPhone6plus 之间执行不同的结果

我在 render() 函数中的代码

render: function(){
return (
<View>
<ListView
scrollEnabled={false}
contentContainerStyle={styles.list}
dataSource={dataSource.cloneWithRows(values)}
initialListSize={values.length}
pageSize={3}
scrollRenderAheadDistance={500}
renderRow={this._renderRow}
/>
</View>
);
},

样式:

var styles = StyleSheet.create({
list: {
flexDirection: 'row',
flexWrap: 'wrap',
},
row: {
backgroundColor:'white',
width:w.width/3,
height: w.width/3,
borderWidth: 0.5,
borderColor: '#f3f3f3',
alignItems: 'center',
}});

在iPhone6上运行,没问题! enter image description here

但运行在iPhone6Plus enter image description here

最佳答案

你不应该将 borderWidth 设置为 iPhone6Plus 的 float 。

尝试将 borderWidth: 0.5 替换为 borderWidth: 1

至于为什么,sorry,我不懂deep的原理。

我只知道在 iPhone6Plus 中 PixelRatio.get() === 3,你应该将宽度设置为一个数字,如

宽度 * PixelRatio.get() = [一个整数]

关于ios - react native :Strange Behaviour backgroundColor in ListView running in iphone6Plus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37381894/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com