0

I want to create a stylesheets for my Titanium app. I'm not using Alloy framework, so how i can use app.tss? in which directory i need to store it?

Thank you

Premier
  • 4,160
  • 6
  • 44
  • 58

2 Answers2

4

You can't.

.tss files are features bring by Alloy. However, if you want to use custom styles, you may have a look to the applyProperties method.

You can maybe do some workaround like this :

http://tifiddle.com/e9b87d0f3debd5e4a7bab3beb03dbddd

// Create window object
var win = Ti.UI.createWindow(),
    label = Ti.UI.createLabel();

// Create or import properties
var properties = {
    window: {
        backgroundColor: "#1DB7FF"   
    },

    label: {
        text: "I Love Titanium",
        color: "#FFFFFF"
    }
};

// Apply properties
win.applyProperties(properties.window);
label.applyProperties(properties.label);

// Build views and launch
win.add(label);
win.open();
KtorZ
  • 859
  • 6
  • 12
1

You can use CommonJS to achieve this

resources/styles.js

exports.Window = {
  backgroundColor: 'blue', 
  backgroundImage: '/images/homebg.png',
  exitOnClose: true
};
exports.Label = {
  color: 'gray',
  textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
  backgroundColor: 'transparent', 
  font: { 
    fontFamily:'Helvetica', 
    fontSize: '12dp', 
    fontStyle: 'normal', 
    fontWeight: 'normal' 
  }
};

Usages

var homeWin = Ti.UI.createWindow(require('styles').Window);

You can also refer this

Suraj kochale
  • 973
  • 5
  • 14