Skip to content

Commit 971c2b6

Browse files
committed
fix text color
1 parent 542fbd3 commit 971c2b6

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tooltip.show({
3030
margin: [0, 0, 0, 0],
3131
padding: [0, 0, 0, 0],
3232
color: "yellow",
33-
textColor: "black",
33+
textColor: "black", // Optional
3434
},
3535
android: {
3636
position: "bottom",
@@ -89,7 +89,7 @@ export interface Options {
8989
padding: Array<any>;
9090
margin: Array<any>;
9191
color: string;
92-
textColor: string;
92+
textColor?: string;
9393
};
9494
android?: {
9595
position?: ToolTipPosition;

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-tooltip-ns",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "NativeScript Tooltip",
55
"main": "tooltip-ns",
66
"typings": "index.d.ts",

src/tooltip-ns.common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface Options {
99
padding: Array<any>;
1010
margin: Array<any>;
1111
color: string;
12-
textColor: string;
12+
textColor?: string;
1313
};
1414
android?: {
1515
position?: ToolTipPosition;

src/tooltip-ns.ios.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ export class TooltipNs {
1010

1111
public show(options: Options) {
1212
let self = Frame.topmost().ios.controller;
13-
var nsAttributed = NSAttributedString.alloc().initWithStringAttributes(
14-
options.message,
15-
new NSDictionary(
16-
[new Color(options.ios.textColor).ios],
17-
[NSForegroundColorAttributeName]
18-
)
19-
);
13+
let nsAttributed;
2014

21-
let nsAttributed = NSAttributedString.alloc().initWithString(
22-
options.message
23-
);
15+
if (
16+
options.ios.textColor.length > 0 &&
17+
typeof options.ios.textColor !== "undefined"
18+
) {
19+
nsAttributed = NSAttributedString.alloc().initWithStringAttributes(
20+
options.message,
21+
new NSDictionary(
22+
[new Color(options.ios.textColor).ios],
23+
[NSForegroundColorAttributeName]
24+
)
25+
);
26+
} else {
27+
nsAttributed = NSAttributedString.alloc().initWithString(options.message);
28+
}
2429

2530
this.tooltip = SexyTooltip.alloc().initWithAttributedStringSizedToViewWithPaddingAndMargin(
2631
nsAttributed,

0 commit comments

Comments
 (0)