react native实现自定义导航栏

左手的ㄟ右手 2022-12-27 07:13 330阅读 0赞
  1. const ImageHeader = props => (
  2. <View style={
  3. {position: "relative", height: 80}}>
  4. {/* <Image
  5. style={
  6. {position: "absolute", zIndex: -1, width: "100%", height: 80, resizeMode: "cover"}}
  7. source={require('../../image/bac_nav_top.png')}
  8. /> */}
  9. <View {...props} style={
  10. { flexDirection: 'row',position:"absolute",top:"50%",marginTop:-20,}}>
  11. {/* <Image style={
  12. { width: 24, height: 26 }} source={require('../image/kefu_top.png')} /> */}
  13. <Image style={
  14. { width: 35, height: 35, marginLeft: 25 }} source={require('../../image/kefu.png')} />
  15. <Text style={
  16. { fontSize: 20, fontWeight: '900', color: '#ebd598', marginLeft: 15 , marginTop: 5}}>文本</Text>
  17. <TouchableWithoutFeedback {...props} onPress={() => navigation.navigate("Me")}>
  18. <Icon style={
  19. { padding: 5, marginRight: 5, marginLeft: 38 }} name="user-circle" size={35} />
  20. </TouchableWithoutFeedback>
  21. </View>
  22. </View>
  23. );
  24. navigation.setOptions({
  25. title: '顶部导航栏',
  26. headerStyle: {
  27. height:80,
  28. borderBottomWidth: 0,
  29. //背景颜色必须为透明,不然无法透出底部图片
  30. backgroundColor: "transparent",
  31. //安卓中不添加此属性会导致背景图无法铺满
  32. elevation: 0,
  33. //标题居中
  34. alignSelf: "center",
  35. headerTransparent:true,
  36. },
  37. header:props=>{
  38. return <ImageHeader />;
  39. }
  40. });

发表评论

表情:
评论列表 (有 0 条评论,330人围观)

还没有评论,来说两句吧...

相关阅读