Sumit
Sumit

Reputation: 3078

Xamarin iOS button width change according to text

I have a multi-lingual app and text size can vary according to language.

What i am trying to achieve is resize the button according to space text has taken. Text will only be a one word so width of button will never become so large that it goes out of the screen boundaries.

Is there a way in Xamarin iOS to do it ?

Upvotes: 0

Views: 1230

Answers (1)

Cheesebaron
Cheesebaron

Reputation: 24470

Have you tried just doing something like this:

var button = new UIButton();
button.SetTitle("Some text", UIControlState.Normal);
button.SizeToFit();
View.AddSubview(button);

Upvotes: 1

Related Questions