@@ -486,23 +486,21 @@ export class Label extends LabelBase {
486
486
}
487
487
this . _requestLayoutOnTextChanged ( ) ;
488
488
}
489
- [ colorProperty . setNative ] ( value : Color | UIColor ) {
490
- const color = value instanceof Color ? value . ios : value ;
491
- // if (!this.formattedText && !this.html) {
489
+ [ colorProperty . setNative ] ( value : Color | string ) {
490
+ const color = ! value || value instanceof Color ? ( value as Color ) : new Color ( value ) ;
492
491
const nativeView = this . nativeTextViewProtected ;
493
- nativeView . textColor = color ;
494
- // }
492
+ nativeView . textColor = color ? color . ios : null ;
495
493
}
496
- [ linkColorProperty . setNative ] ( value : Color | UIColor ) {
497
- const color = value instanceof Color ? value . ios : value ;
494
+ [ linkColorProperty . setNative ] ( value : Color | string ) {
495
+ const color = ! value || value instanceof Color ? ( value as Color ) : new Color ( value ) ;
498
496
const nativeView = this . nativeTextViewProtected ;
499
497
let attributes = nativeView . linkTextAttributes ;
500
498
if ( ! ( attributes instanceof NSMutableDictionary ) ) {
501
499
attributes = NSMutableDictionary . new ( ) ;
502
500
}
503
- attributes . setValueForKey ( color , NSForegroundColorAttributeName ) ;
504
- if ( this . linkUnderline !== false ) {
505
- attributes . setValueForKey ( color , NSUnderlineColorAttributeName ) ;
501
+ if ( this . linkUnderline !== false && color ) {
502
+ attributes . setValueForKey ( color . ios , NSForegroundColorAttributeName ) ;
503
+ attributes . setValueForKey ( color . ios , NSUnderlineColorAttributeName ) ;
506
504
} else {
507
505
attributes . setValueForKey ( UIColor . clearColor , NSUnderlineColorAttributeName ) ;
508
506
}
@@ -518,8 +516,9 @@ export class Label extends LabelBase {
518
516
attributes = NSMutableDictionary . new ( ) ;
519
517
}
520
518
if ( value ) {
521
- if ( this . linkColor ) {
522
- attributes . setValueForKey ( this . linkColor . ios , NSUnderlineColorAttributeName ) ;
519
+ const color = ! this . linkColor || this . linkColor instanceof Color ? this . linkColor : new Color ( this . linkColor ) ;
520
+ if ( color ) {
521
+ attributes . setValueForKey ( color . ios , NSUnderlineColorAttributeName ) ;
523
522
} else {
524
523
attributes . removeObjectForKey ( NSUnderlineColorAttributeName ) ;
525
524
}
@@ -607,7 +606,10 @@ export class Label extends LabelBase {
607
606
dict . set ( NSFontAttributeName , this . nativeTextViewProtected . font ) ;
608
607
}
609
608
if ( style . color ) {
610
- dict . set ( NSForegroundColorAttributeName , style . color . ios ) ;
609
+ const color = ! style . color || style . color instanceof Color ? style . color : new Color ( style . color ) ;
610
+ if ( color ) {
611
+ dict . set ( NSForegroundColorAttributeName , color . ios ) ;
612
+ }
611
613
}
612
614
const result = NSMutableAttributedString . alloc ( ) . initWithString ( source ) ;
613
615
result . setAttributesRange ( dict as any , {
0 commit comments