Aron
Aron

Reputation: 1179

Nativescript iOS UIColor

I want set the NavigationBar/ActionBar Color to Transparent/Clear in Nativescript.

import {BasePage} from "../../shared/BasePage";
import frameModule = require("ui/frame");
import {topmost} from "ui/frame";
import {Observable, EventData} from "data/observable";
import {View} from "ui/core/view";

class HomePage extends BasePage{

   mainContentLoaded(args:EventData){
       let view = <View>args.object;

       if(view.ios){
          var controller = frameModule.topmost().ios.controller;
          controller.navigationBar.barTintColor = UIColor.redColor();
       }

       view.bindingContext = new Observable({ myText: 'This is the home page' });
   }
}
   export = new HomePage();

But i get this error: "error TS2304: Cannot find name 'UIColor'"

What i doing wrong?

Thanks for help

Upvotes: 0

Views: 1398

Answers (1)

Dean Le
Dean Le

Reputation: 2094

I suggest you to use the NS color module and convert it to iOS color, so that you can use any color that you want. Like this:

var colorModule = require("color");
var red = new colorModule.Color("#ff0000");

var controller = frameModule.topmost().ios.controller;
controller.navigationBar.barTintColor = red.ios;

Upvotes: 4

Related Questions