Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

UIBarButtonItem and SetTitlePositionAdjustment

$
0
0

I have a toolbar in my code with two buttons: toolbar code: UIToolbar toolbar = new UIToolbar (); toolbar.BarStyle = UIBarStyle.Default; toolbar.Translucent = true; toolbar.Alpha = 0.6f; toolbar.SizeToFit (); float toolbarButtonWidth = UIScreen.MainScreen.Bounds.Width; float toolbarButtonHeight = 52f; toolbar.Frame = new RectangleF (UIScreen.MainScreen.Bounds.Width - toolbarButtonWidth, UIScreen.MainScreen.Bounds.Height - toolbarButtonHeight - 20, toolbarButtonWidth, toolbarButtonHeight); this.View.AddSubview (toolbar);

my toolbar has to buttons: UIBarButtonItem doneButton = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Done, (s, e) => { //bla bla bla } }); doneButton.Width = UIScreen.MainScreen.Bounds.Width / 2.3f; And a similar cancel button

My problem is that my two buttons titles are not in the center of the view. I try align them with UIOffset offset = new UIOffset (); offset.Vertical = 3f; offset.Horizontal = -10f; doneButton.SetTitlePositionAdjustment (offset, UIBarMetrics.Default); but nothing happened. What I am doing wrong? What can I do to correctly show my buttons (their titles basically).


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>