Reputation: 135
I have tried the code below but text image gets overlapped.
btnBack.SetImage(UIImage.FromFile("Images/arrow-back.png"), UIControlState.Normal);
btnBack.TintColor = UIColor.White;
Upvotes: 0
Views: 480
Reputation: 14475
This is a normal issue when setting text and image simultaneously on Button.
You can use TitleEdgeInsets
and ImageEdgeInsets
to get rid of it.
For example:
button.ImageEdgeInsets = new UIEdgeInsets(0, -10, 0, 0);
button.TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, -10);
Moreover, you can also create a UIView
which contains image and text, in this way it is more controllable.
Upvotes: 1