屬性:hairlineWidth: 自適應不同設備生成一條線
var styles = StyleSheet.create({ separator: { borderBottomColor: '#bbb', borderBottomWidth: StyleSheet.hairlineWidth, }, });
屬性:adsoluteFill:
const styles = StyleSheet.create({ wrapper: { ...StyleSheet.absoluteFill, top: 10, backgroundColor: 'transparent', }, });
相當於以下代碼的縮寫:
position: 'absolute', left: 0, right: 0, top: 0, bottom: 0
方法:create: 根據對象創建樣式表
StyleSheet.create({ textColor: { color: #000 } })
方法:flatten: 可以把樣式對象的數組整合成一個樣式對象,重復的樣式屬性以后一個為准
var styles = StyleSheet.create({ listItem: { flex: 1, fontSize: 16, color: 'white', }, selectedListItem: { color: 'green', }, }); console.log(StyleSheet.flatten([styles.listItem, styles.selectedListItem])); // returns { flex: 1, fontSize: 16, color: 'green' }