Use of Native UI elements


#1

I am trying to understand how to use native UI elements in Nativescript in xml file.

I tried following inside a gridlayout.

<Button ios:text="I'm an iOS button!" android:text="I'm an Android button!" row="0" column="0" style.backgroundColor="green"> 
</Button> 
<ios>
  <UIButton text="I'm an iOS button!"  row="0" column="1" style.backgroundColor="blue"> 
  </UIButton> 
 </ios>

First button(green) does show up but not second one.
What am I doing wrong?

I am able to acess native componenents in my code :
e.g. private myIOSButton: UIButton;

Thanks.


#2

UIButton is not a NativeScript widget so you can’t use that. If you rename <UIButton> to <Button> it will probably show up on iOS as well. Not on Android, because you’ve restricted it to only be included on iOS with those <ios> tags.


#3

Yes, I am using iOS.

Thank you for the response.