zoukankan      html  css  js  c++  java
  • React-Native学习(一)

    一、Text 相当于安卓中的TextView或者OC中的Label,专门用来显示基本的文本信息;除了基本的显示布局之外,可以进行嵌套显示,设置样式,以及可以做事件(例如:点击)处理;
     
    二、Text组件常用的属性方法
    Attributes.style = {
        color string
        containerBackgroundColor string
        fontFamily string
        fontSize number
        fontStyle enum('normal', 'italic')
        fontWeight enum("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')
        lineHeight number
        textAlign enum("auto", 'left', 'right', 'center')
        writingDirection enum("auto", 'ltr', 'rtl')
    numberOfLines number
    textAlign (
    "auto", 'left', 'right', 'center', 'justify')
    fontWeight (
    "normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') onPress fcuntion
    }

    注释如下:

    `color` 字体颜色

     `numberOfLines` (number) 进行设置Text显示文本的行数,如果显示的内容超过了行数,默认其他多余的信息就不会显示了

    `onPress` (fcuntion)  该方法当文本发生点击的时候调用该方法

     `color`  字体颜色

    `fontFamily`  字体名称

    `fontSize`  字体大小

    `fontStyle`   字体风格(normal,italic)

    `fontWeight ` 字体粗细权重("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')

    `textShadowOffset`  设置阴影效果{ number, height: number}

    `textShadowRadius`  阴影效果圆角

    `textShadowColor`  阴影效果的颜色

    `letterSpacing`  字符间距

    `lineHeight`  行高

    `textAlign`   文本对其方式("auto", 'left', 'right', 'center', 'justify')

    `textDecorationLine`  横线位置 ("none", 'underline', 'line-through', 'underline line-through')

    `textDecorationStyle` 线的风格("solid", 'double', 'dotted', 'dashed')

     `textDecorationColor` 线的颜色

    `writingDirection` 文本方向("auto", 'ltr', 'rtf')

    三、Text组件中常用的属性的应用

    <Text style={styles.wl_textStyle} numberOfLines={5}>
    我是一段有个性的文字, haahahh,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
    </Text>

    wl_textStyle: {
    backgroundColor: 'red', // 背景色
    color: 'yellow', // 字体颜色
    textAlign: 'right',
    200,
    lineHeight: 30,
    fontSize: 18,
    fontWeight: 'bold',
    letterSpacing:5, // 字符间距
    textDecorationLine: 'underline', // 横线位置 ("none", 'underline', 'line-through', 'underline line-through')
    textDecorationStyle: 'double', // 线的风格("solid", 'double', 'dotted', 'dashed')
    textDecorationColor: 'black' // 线的颜色
    }
    
    
    四、Text组件中样式的继承
    在React-native中是没有样式继承这种说法的, 但是对于Text元素里边的Text元素,其实是能够继承的,那么是单层继承还是多层继承?
    <Text style={{color: 'yellow', fontSize: 11}}>
    <Text>
    <Text style={styles.wl_textStyle} numberOfLines={5}>
    我是一段有个性的文字, haahahh,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
    </Text>
    </Text>

    </Text>
    
    
    
    
    
  • 相关阅读:
    ScrollView 实现循环轮播
    UINavigationController和UITabBarController合用
    iOS开发网络篇—网络编程基础
    iOS开发网络篇—搭建本地服务器
    iOS开发网络篇—HTTP协议
    iOS开发网络篇—GET请求和POST请求
    UIView
    iOS准备程序
    iOS小程序-混合计算器
    IOS入门-计算机小程序
  • 原文地址:https://www.cnblogs.com/10-19-92/p/6479774.html
Copyright © 2011-2022 走看看