README.md 7.27 KB
Newer Older
李晓兵's avatar
李晓兵 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
<!---
# license: Licensed to the Apache Software Foundation (ASF) under one
#         or more contributor license agreements.  See the NOTICE file
#         distributed with this work for additional information
#         regarding copyright ownership.  The ASF licenses this file
#         to you under the Apache License, Version 2.0 (the
#         "License"); you may not use this file except in compliance
#         with the License.  You may obtain a copy of the License at
#
#           http://www.apache.org/licenses/LICENSE-2.0
#
#         Unless required by applicable law or agreed to in writing,
#         software distributed under the License is distributed on an
#         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#         KIND, either express or implied.  See the License for the
#         specific language governing permissions and limitations
#         under the License.
-->

# cordova-plugin-statusbar

[![Build Status](https://travis-ci.org/apache/cordova-plugin-statusbar.svg)](https://travis-ci.org/apache/cordova-plugin-statusbar)

# StatusBar

> Il `StatusBar` oggetto fornisce alcune funzioni per personalizzare l'iOS e Android StatusBar.

## Installazione

    cordova plugin add cordova-plugin-statusbar
    

## Preferenze

#### config. XML

  * **StatusBarOverlaysWebView** (boolean, default è true). IOS 7, rendono la statusbar sovrapposizione o la non sovrapposizione WebView all'avvio.
    
        <preference name="StatusBarOverlaysWebView" value="true" />
        

  * **StatusBarBackgroundColor** (stringa esadecimale di colore, il valore predefinito è #000000). Su iOS 7 e 5 Android, è possibile impostare il colore di sfondo della barra di stato di una stringa esadecimale (#RRGGBB) all'avvio.
    
        <preference name="StatusBarBackgroundColor" value="#000000" />
        

  * **StatusBarStyle** (status bar in stile, default è lightcontent). IOS 7, impostare lo stile di barra di stato. Predefinita di opzioni disponibili, lightcontent, blacktranslucent, blackopaque.
    
        <preference name="StatusBarStyle" value="lightcontent" />
        

### Stranezze Android

Le linee 5 + Android Guida specificano utilizzando un colore diverso per la barra di stato che l'app principale di colore (a differenza di colore uniforme statusbar di molte applicazioni di iOS 7 +), quindi si consiglia di impostare il colore della barra di stato in fase di esecuzione invece tramite `StatusBar.backgroundColorByHexString` o `StatusBar.backgroundColorByName`. Un modo per farlo sarebbe:

```js
if (cordova.platformId == 'android') {
    StatusBar.backgroundColorByHexString("#333");
}
```

## Nascondendo all'avvio

In fase di esecuzione è possibile utilizzare la funzione di StatusBar.hide qui sotto, ma se si desidera che la barra di stato venga nascosta all'avvio di app, è necessario modificare il file info. plist dell'app.

Aggiungere o modificare questi due attributi, se non presente. Impostare la **"barra di stato è inizialmente nascosto"** a **"YES"** e **"Aspetto di vista basati su controller status bar"** a **"NO"**. Se si modifica manualmente senza Xcode, le chiavi e i valori sono:

    <key>UIStatusBarHidden</key>
    <true/>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    

## Metodi

Questo plugin definisce globale oggetto `StatusBar`.

Anche se in ambito globale, non è disponibile fino a dopo l'evento `deviceready`.

    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        console.log(StatusBar);
    }
    

  * StatusBar.overlaysWebView
  * StatusBar.styleDefault
  * StatusBar.styleLightContent
  * StatusBar.styleBlackTranslucent
  * StatusBar.styleBlackOpaque
  * StatusBar.backgroundColorByName
  * StatusBar.backgroundColorByHexString
  * StatusBar.hide
  * StatusBar.show

## Proprietà

  * StatusBar.isVisible

## Autorizzazioni

#### config. XML

            <feature name="StatusBar">
                <param name="ios-package" value="CDVStatusBar" onload="true" />
            </feature>
    

# StatusBar.overlaysWebView

IOS 7, rendono la statusbar sovrapposizione o non sovrapporre WebView.

    StatusBar.overlaysWebView(true);
    

## Descrizione

IOS 7, impostato su false per rendere la barra di stato vengono visualizzati come iOS 6. Impostare il colore di sfondo e stile per soddisfare utilizzando altre funzioni.

## Piattaforme supportate

  * iOS

## Esempio rapido

    StatusBar.overlaysWebView(true);
    StatusBar.overlaysWebView(false);
    

# StatusBar.styleDefault

Utilizzare la barra di stato predefinito (testo scuro, per sfondi di luce).

    StatusBar.styleDefault();
    

## Piattaforme supportate

  * iOS
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.styleLightContent

Utilizzare la barra di stato lightContent (testo in chiaro, per sfondi scuri).

    StatusBar.styleLightContent();
    

## Piattaforme supportate

  * iOS
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.styleBlackTranslucent

Utilizzare la barra di stato blackTranslucent (testo in chiaro, per sfondi scuri).

    StatusBar.styleBlackTranslucent();
    

## Piattaforme supportate

  * iOS
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.styleBlackOpaque

Utilizzare la barra di stato blackOpaque (testo in chiaro, per sfondi scuri).

    StatusBar.styleBlackOpaque();
    

## Piattaforme supportate

  * iOS
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.backgroundColorByName

IOS 7, quando StatusBar.statusBarOverlaysWebView è impostata su false, è possibile impostare il colore di sfondo della barra di stato con il nome di colore.

    StatusBar.backgroundColorByName("red");
    

Nomi di colore supportati sono:

    black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown
    

## Piattaforme supportate

  * iOS
  * Android 5+
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.backgroundColorByHexString

Imposta il colore di sfondo della barra di stato di una stringa esadecimale.

    StatusBar.backgroundColorByHexString("#C0C0C0");
    

Proprietà di scrittura stenografica CSS sono supportati anche.

    StatusBar.backgroundColorByHexString("#333"); // => #333333
    StatusBar.backgroundColorByHexString("#FAB"); // => #FFAABB
    

IOS 7, quando StatusBar.statusBarOverlaysWebView è impostata su false, è possibile impostare il colore di sfondo della barra di stato di una stringa esadecimale (#RRGGBB).

Su WP7 e WP8 è inoltre possibile specificare i valori come #AARRGGBB, dove AA è un valore alfa

## Piattaforme supportate

  * iOS
  * Android 5+
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.hide

Nascondere la barra di stato.

    StatusBar.hide();
    

## Piattaforme supportate

  * iOS
  * Android
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.show

Mostra la barra di stato.

    StatusBar.show();
    

## Piattaforme supportate

  * iOS
  * Android
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1

# StatusBar.isVisible

Leggere questa proprietà per vedere se la barra di stato è visibile o no.

    if (StatusBar.isVisible) {
        // do something
    }
    

## Piattaforme supportate

  * iOS
  * Android
  * Windows Phone 7
  * Windows Phone 8
  * Windows Phone 8.1