PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

Styling Accessory View #131

Closed jacobbundren closed 6 years ago

jacobbundren commented 7 years ago

Is there any way to style the accessory view on ios? We'd like to keep it but can't figure out how to change the background color of the bar or change the value of the Done button text.

PeterStaev commented 6 years ago

Hey @jacobbundren , you can access the native toolbar via dropDown._toolbar this is an instance of UIToolbar. The native done button you can access via dropDown._doneButton this is an instance of UIBarButtonItem. Then you should be able to style those using their respective native properties.

PeterStaev commented 6 years ago

No further response so closing this one for now. In case you still have problems, please provide more details.

jacobbundren commented 6 years ago

@PeterStaev I'm not sure that I'm following. dropDown doesn't seem to have properties named _toolbar and _doneButton. Also, the following console logs all return undefined. Are you referencing this in a different way?

@ViewChild("dd") private _dd: DropDown;

public onOpen(): void {
     console.log(this._dd);
     console.log(this._dd._toolbar);
     console.log(this._dd._doneButton);
}
PeterStaev commented 6 years ago

@jacobbundren , that's because you are using angular and in this case dd is not a drop down but an angular element ref. So you will need to use this._dd.nativeElement. This will be a reference to the actual widget and then you should have _toolbar and _doneButton. Note that those are private members so they are not exposed through definitions. If you get a TS error simple cast the widget to any like so

(this._dd.nativeElement as any)._toolbar

Hope this helps!