mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
- Use relative imports in place of most of our absolute ones. - Add "private" ambient modules for modules that we need to import using an absolute path (e.g. when app/.../test-something.ts needs to import ui/styling/style-scope)
30 lines
813 B
TypeScript
30 lines
813 B
TypeScript
import common = require("./color-common");
|
|
|
|
var AMP = "#";
|
|
|
|
export class Color extends common.Color {
|
|
private _ios: UIColor;
|
|
|
|
get ios(): UIColor {
|
|
if (!this._ios) {
|
|
// iOS Color is using floating-point values in the [0, 1] range, so divide the components by 255
|
|
this._ios = UIColor.alloc().initWithRedGreenBlueAlpha(this.r / 255, this.g / 255, this.b / 255, this.a / 255);
|
|
}
|
|
return this._ios;
|
|
}
|
|
|
|
public _argbFromString(hex: string): number {
|
|
if (hex.charAt(0) === AMP) {
|
|
hex = hex.substr(1);
|
|
}
|
|
|
|
var intVal = parseInt(hex, 16);
|
|
if (hex.length === 6) {
|
|
// add the alpha component since the provided string is RRGGBB
|
|
intVal |= 255 << 24;
|
|
}
|
|
|
|
return intVal;
|
|
}
|
|
}
|