Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EddyVerbruggen/bb10f8f1114c06007efa3d239e92b66b to your computer and use it in GitHub Desktop.
Save EddyVerbruggen/bb10f8f1114c06007efa3d239e92b66b to your computer and use it in GitHub Desktop.
Change the text color of the selected item in a NativeScript SegmentedBar
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