How to use Titanium app.tss in classic mobile app

176 Views Asked by At

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

2

There are 2 best solutions below

3
On BEST ANSWER

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();
0
On

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