Harshad Pansuriya
Harshad Pansuriya

Reputation: 20980

How to set clean Image on Button in ios(Xamarin)

I am new to Xamarin and iOS. I am setting Image on Button via both the way design and programatically.

Design Way :

enter image description here

my Image name is Pen.png.

Programatically Way :

btnEditAccount.SetImage(UIImage.FromFile("Pen.png"), UIControlState.Normal);

But in Both case My Image not set well. It Complete White Image. But on Button it display below Image.

Output :

enter image description here

I Expect :

enter image description here

Is there any Property I miss for my understing ?

How to set full white Image on Button.

Any Help be Appreciated.

Upvotes: 0

Views: 673

Answers (2)

Harshad Pansuriya
Harshad Pansuriya

Reputation: 20980

Finally I set TintColor to Button Image and it will solve the Probelm.

Programatically this way

btnEditAccount.SetImage(UIImage.FromFile("Pen.png"), UIControlState.Normal);
btnEditAccount.TintColor = UIColor.White;

Upvotes: 0

Himanshu Moradiya
Himanshu Moradiya

Reputation: 4815

button.setImage(UIImage.init(named: "icon (5).png"), forState: .Normal)
 button.tintColor = UIColor.clearColor()

Upvotes: 0

Related Questions