React Native組件 --Touchable類&Image&TabBarIOS&WebView

1.Touchable類組件

a.TouchableHighlight組件: 高亮觸摸,出現(xiàn)高亮效果

屬性:

    - activeOpacity : 觸摸時(shí)透明度的設(shè)置
    - onHideUnderlay:隱藏背景陰影時(shí)觸發(fā)該事件
    - onShowUnderlay:出現(xiàn)背景陰影時(shí)觸發(fā)該事件
    - underlayColor:點(diǎn)擊時(shí)背景陰影效果的背景顏色
b.TouchableOpacity:透明觸摸,出現(xiàn)透明過濾效果

屬性:

     activeOpacity:觸摸時(shí)透明度的設(shè)置
c.TouchableWitoutFeedback:無反饋性觸摸,不會(huì)出現(xiàn)任何視圖變化
事件:
 onLongPress:長按事件
 onPressIn:觸摸進(jìn)入事件
 onPressOut:觸摸釋放事件

2.Image組件

屬性及事件
- resizeMode:枚舉類型。cover、contain、stretch;表示圖片適應(yīng)的模式;
   - Image.resizeMode.cover:圖片居中顯示,沒有被拉伸,超出部分被截?cái)?   - Image.resizeMode.contain:容器完全容納圖片,圖片等比例進(jìn)拉伸
   - Image.resizeMode.stretch:圖片被拉伸適應(yīng)容器大小,有可能會(huì)發(fā)生變形
- source:圖片的引用地址,{uri:string}如果是一個(gè)本地的靜態(tài)資源;那么需要使用- require(’image!name’)包裹
- defaultSource:表示默認(rèn)的圖片地址。
- onLoad:加載成功時(shí)觸發(fā)該事件
- onLoadEnd :不管加載失敗還是加載成功,都會(huì)觸發(fā)該事件
- onLoadStart:加載開始時(shí)觸發(fā)
- onProgress:加載過程的進(jìn)度事件

注:
本地圖片:<Image source = { require(‘image!my-icon')}/> // 加載xcode中的圖片

3.TabBarIOS組件

屬性:
barTintColor :tab欄的背景顏色
tintColor:選中tab的圖標(biāo)顏色
translucent:tab欄是否透明
TabBarIOS.Item組件屬性及事件:
badge:紅色的提示數(shù)字
icon:tab圖標(biāo)
onPress:點(diǎn)擊事件;注:其中一個(gè)tab被選中時(shí),需要改變?cè)摻M件的selected = {true}
selected:是否選中某個(gè)tab;
selectedIcon:選中狀態(tài)的圖標(biāo);如果為空?qǐng)D標(biāo)變?yōu)樗{(lán)色;類似于iOS系統(tǒng)默認(rèn)渲染圖片;
systemIcon:系統(tǒng)圖標(biāo);枚舉類型:bookmarks,contacts,downloads,favorites,featured,history,more,most-recent,most-viewed,recents,search,top-rated;
title:標(biāo)題;出現(xiàn)在圖標(biāo)底部;使用系統(tǒng)圖標(biāo)時(shí),會(huì)忽略該標(biāo)題;
      <TabBarIOS style = {styles.flex}>
           <TabBarIOS.Item
              title = "消息"
              icon = {require("image!message")}
              onPress = {this.select.bind(this,'message')}
              selected = {this.state.tab == 'message'}>
           </TabBarIOS.Item>
           <TabBarIOS.Item
              title = "聯(lián)系人"
              icon = {require("image!phone")}
              onPress = {this.select.bind(this,'phonelist')}
              selected = {this.state.tab == 'phonelist'}>
        </TabBarIOS.Item>
      </TabBarIOS>

4.WebView組件

屬性及事件
automaticallyAdjustContentInsets:表示是否自動(dòng)調(diào)整內(nèi)部內(nèi)容,
bounces:回彈效果,默認(rèn)為true;
contentInset:內(nèi)部內(nèi)容偏移值,{top:number,left:number,bottom:number,right:number}
html:html代碼字符串
injectedJavaScript:注入的JavaScript代碼,
onNavigationStateChange:監(jiān)聽導(dǎo)航狀態(tài)變化的函數(shù)
renderError:監(jiān)聽渲染頁面出錯(cuò)的函數(shù)
startInLoadingState:是否開啟頁面加載的狀態(tài)
renderLoading:webview組件正在渲染頁面時(shí)觸發(fā)的函數(shù),startInLoadingState為true時(shí)才起作用;
scrollEnabled:表示webview 頁面是否能滾動(dòng);
onNavigationStateChange:按照頁面比例和內(nèi)容寬高比例自動(dòng)縮放內(nèi)容;
        <WebView
        injectedJavaScript = "alert('歡迎使用React Native')"
        bounces = {false}
        url = 'http://weibo.com'
        style = {{width:width,height:height}}>
        </WebView>
        <WebView
        contentInset = {{left:100,top:180}}
        scrollEnabled = {false}
        html = '<div> <img  src = "http://upload.jianshu.io/users/upload_avatars/1109379/e9bb0a950f29.jpg?imageMogr/thumbnail/90x90/quality/100"/></div>'
        style = {{width:width,height:height}}>
        </WebView>

注:
xcode訪問HTTP時(shí)需要做一下配置


網(wǎng)絡(luò)配置
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容