-1
Q
阵营本地同心圆
A
回答
1
实现此目的有很多方法。尽管这个问题不适合在StackOverflow上,但我在这里做了一些代码来帮助你。
import React from 'react'
import {
StyleSheet,
TouchableOpacity,
View
} from 'react-native'
export default class AboutScreen extends React.Component {
render() {
return (
<View style={styles.container}>
<View style={styles.circlesContainer}>
<TouchableOpacity style={styles.circle_1} />
<TouchableOpacity style={styles.circle_2} />
<TouchableOpacity style={styles.circle_3} />
</View>
</View>
)
}
}
// Base radius.
const BASE_SIZE = 300
const styles = StyleSheet.create({
container: {
flex:1,
alignItems:'center',
justifyContent: 'center',
backgroundColor: '#E56A00'
},
circlesContainer:{
width: BASE_SIZE,
height: BASE_SIZE,
alignItems: 'center',
},
circle_1:{
top:0,
position: 'absolute',
width:BASE_SIZE,
height:BASE_SIZE,
borderRadius: BASE_SIZE/2,
backgroundColor: '#FF8100'
},
circle_2:{
top:BASE_SIZE*0.1, // The amount remaining
left:BASE_SIZE*0.1,
position: 'absolute',
width:BASE_SIZE*0.8, // 80% of the base size
height:BASE_SIZE*0.8,
borderRadius: BASE_SIZE/2,
backgroundColor: '#FF9D2E'
},
circle_3:{
top:BASE_SIZE*0.2,
left:BASE_SIZE*0.2,
position: 'absolute',
width:BASE_SIZE*0.6,
height:BASE_SIZE*0.6, // 60% of the base size
borderRadius: BASE_SIZE*0.6/2,
backgroundColor: '#FFFFFF'
},
})
在我的代码,结果是这样的:
要知道,有很多的方法来优化这个代码,但至少它可能是一个良好的开端给你。
祝你好运!
-1
您可以使用具有borderRadius的视图,由另一个视图环绕,也可以使用borderRadius。
<View style={styles.borderExternal}>
<View style={styles.myCircle} />
</View>
相关问题
- 1. 阵营本地FlatList
- 2. 阵营本地TouchableNativeFeedback
- 3. 阵营本地JSONSerialization
- 4. 在阵营本地
- 5. AsyncStorage.getItem回报:阵营本地
- 6. 阵营本地_weakMap2错误
- 7. PanResponder阵营本地参数
- 8. 预取阵营本地
- 9. NavigatorIOS错误 - 阵营本地
- 10. 阵营本地StackNavigator initialRouteName
- 11. 阵营本地国有
- 12. 阵营本地Relay文档
- 13. 导航在阵营本地
- 14. 阵营本地和Couchbase
- 15. 阵营本地安装
- 16. 如何实现谷歌地图在阵营Android本地(阵营 - 本机地图)
- 17. 中心图片阵营本地加载屏幕
- 18. 阵营本地地图liteMode不工作
- 19. 阵营本地火力地堡DataSnapshot
- 20. 火力地堡FCM - 阵营本地
- 21. 阵营本地路由VS阵营导航
- 22. 渲染图像文本阵营本地
- 23. 阵营在地图
- 24. 动态inilne风格阵营本地
- 25. 阵营本地渲染Facebook登录
- 26. “全球”模态在阵营本地
- 27. 阵营本地TouchableHighlit OnPress功能
- 28. 在导入文件阵营本地
- 29. 阵营本地不能解析模块
- 30. 获得props.navigation在阵营本地