Pergunta

All my Passbook environment works fine (PHP/MySQL based server for pass generation and signing, and the pass download - webview based download, emailing the pass or presenting inside my app with PassKit).

The only thing that is not working is the color of the labelColor in the primary fields of a coupon type pass.

I have (in the pass.json file):

"foregroundColor" : "rgb(30, 30, 30)",
"backgroundColor" : "rgb(230, 230, 230)",
"labelColor" : "rgb(30, 30, 30)",

The foregroundColor and backgroundColor work fine, but the labelColor (presented on top of the strip image) is white, instead of the labelColor specified.

According to Apple´s Passbook package reference, the labelColor is optional

"Optional. Color of the label text, specified as a CSS-style RGB triple. For example, rgb(255, 255, 255). If omitted, the label color is determined automatically."

In this case, the strip image is a clear image so, the text should be black (even if labelColor omitted and the color determined automatically), but the try appears white in the pass

Any help would be appreciated.

... e

Foi útil?

Solução

Label and foreground colors are only applied to primary field labels and values when there is no strip image in the pass. Where a strip image exists, the text color is automatically changed to white.

There is an undocumented parameter stripColor that can be used to set the colour of the text over a strip image. This changes both the field and the label.

This parameter has been around since the early iOS6 betas. However, use with caution. Just because it works today is no guarantee it will work in the future.

enter image description here

Outras dicas

I found that using the "stripColor" does change the text in the strip outside of the "foregroundColor" parameter. This is still the case in iOS 8+

Here is example of where to put the "stripColor" in the json.

passJson = {
  "formatVersion": 1,
  "passTypeIdentifier": "pass type goes here",
  "serialNumber": "serialNumber goes here",
  "teamIdentifier": "",
  "organizationName": "",
  "description": "",
  "logoText": "My Logo",
  "foregroundColor": "rgb(150,0,150)",
  "backgroundColor": "rgb(255, 255, 255)",
  "labelColor": "rgb(0, 0, 0)",
  "stripColor": "rgb(255,255,255)",
  "associatedStoreIdentifiers": [

  ],
  "associatedApps": [
    {
      "title": "Name of your app"
    }
  ],
  "barcode": {
    "message": "coupon",
    "format": "PKBarcodeFormatPDF417",
    "messageEncoding": "iso-8859-1",
    "altText": "coupon"
  },
  "coupon": {
    "primaryFields": [
      {
        "key": "offer",
        "label": "Offer text 2",
        "value": "Offer text 1"
      }
    ],
    "secondaryFields": [
      {
        "label": "Expires",
        "value": "09/26/2015",
        "key": "expires"
      }
    ],
    "backFields": [
      {
        "label": "TERMS AND CONDITIONS",
        "value": "Back of pass",
        "key": "terms"
      }
    ]
  }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top