Last active
December 19, 2017 11:38
-
-
Save EddyVerbruggen/bb10f8f1114c06007efa3d239e92b66b to your computer and use it in GitHub Desktop.
Change the text color of the selected item in a NativeScript SegmentedBar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Color } from "tns-core-modules/color"; | |
declare const UIControlStateSelected: any; | |
export class CheckoutComponent implements OnInit { | |
// this assumes you have this in your html: <SegmentedBar #paymentOptionsBar ..> | |
@ViewChild("paymentOptionsBar") paymentOptionsBar: ElementRef; | |
ngOnInit(): void { | |
if (this.paymentOptionsBar.nativeElement.ios) { | |
let segmentedControl = <UISegmentedControl>this.paymentOptionsBar.nativeElement.ios; | |
let segmentedControlOptions = NSDictionary.dictionaryWithObjectForKey(new Color("blue").ios, NSForegroundColorAttributeName); | |
segmentedControl.setTitleTextAttributesForState(segmentedControlOptions, UIControlState.Selected) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment