Nativescript iOS UIColor
Nativescript iOS UIColor
我想在 Nativescript 中将 NavigationBar/ActionBar 颜色设置为 Transparent/Clear。
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();
但是我得到这个错误:"error TS2304: Cannot find name 'UIColor'"
我做错了什么?
感谢帮助
我建议你使用 NS 颜色模块并将其转换为 iOS 颜色,这样你就可以使用任何你想要的颜色。像这样:
var colorModule = require("color");
var red = new colorModule.Color("#ff0000");
var controller = frameModule.topmost().ios.controller;
controller.navigationBar.barTintColor = red.ios;
我想在 Nativescript 中将 NavigationBar/ActionBar 颜色设置为 Transparent/Clear。
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();
但是我得到这个错误:"error TS2304: Cannot find name 'UIColor'"
我做错了什么?
感谢帮助
我建议你使用 NS 颜色模块并将其转换为 iOS 颜色,这样你就可以使用任何你想要的颜色。像这样:
var colorModule = require("color");
var red = new colorModule.Color("#ff0000");
var controller = frameModule.topmost().ios.controller;
controller.navigationBar.barTintColor = red.ios;