[MonoTouch] Button TitleText Not showing up
bryan costanich
b at wowzer.net
Tue Oct 27 02:24:00 EDT 2009
hey all, i am creating a custom UIActionSheet and i'm adding some stuff to it, so far everything is working, except i set my button's TitleLabel.Text, and the button shows up blank. i've tried changing the colors thinking that it was just a color issue, but that hasn't helped. this is my code, am i doing something wrong?:
//========================================================================
protected void ShowActionSheetPicker (string actionSheetTitle)
{
//---- declare vars
UIActionSheet actionSheet;
UIButton btnDone = UIButton.FromType (UIButtonType.RoundedRect);
UILabel lblActionSheetTitle = new UILabel ();
UIFont titleFont = UIFont.FromName ("helvetica", 18);
float actionSheetWidth = this.View.Frame.Width;
float actionSheetHeight = 310;
float btnDoneWidth = 50;
float btnDoneHeight = 35;
//---- setup our picker view
// it autosizes, so empty is fine
this._lstPicker = new UIPickerView (RectangleF.Empty);
this._lstPicker.ShowSelectionIndicator = true;
this._lstPicker.Model = this._peopleModel;
//---- configure our label
lblActionSheetTitle.Text = actionSheetTitle;
lblActionSheetTitle.BackgroundColor = UIColor.Clear;
lblActionSheetTitle.TextColor = UIColor.White;
lblActionSheetTitle.Font = titleFont;
//---- create + configure the action sheet
actionSheet = new UIActionSheet ("", null, "Cancel", null) { Style = UIActionSheetStyle.Default };
actionSheet.Style = UIActionSheetStyle.BlackTranslucent;
actionSheet.Clicked += delegate(object sender, UIButtonEventArgs args) { Console.WriteLine ("Clicked on item {0}", args.ButtonIndex); };
//---- configure our "done" button
btnDone.TitleLabel.Text = "done";
//btnDone.BackgroundColor = UIColor.DarkGray;
//btnDone.TitleLabel.BackgroundColor = UIColor.DarkGray;
//btnDone.TitleLabel.TextColor = UIColor.White;
//btnDone.TitleLabel.TextColor = UIColor.Black;
//---- show the action sheet and add the controls to it
actionSheet.ShowInView (this.View);
actionSheet.AddSubview (this._lstPicker);
actionSheet.AddSubview (lblActionSheetTitle);
actionSheet.AddSubview (btnDone);
//---- resize the action sheet to fit our other stuff
actionSheet.Frame = new System.Drawing.RectangleF (0f, UIScreen.MainScreen.Bounds.Height - actionSheetHeight, actionSheetWidth, actionSheetHeight);
//---- move our picker to be at the bottom of the actionsheet
float pickerY = actionSheetHeight - this._lstPicker.Frame.Height;
this._lstPicker.Frame = new RectangleF (this._lstPicker.Frame.X, pickerY, this._lstPicker.Frame.Width, this._lstPicker.Frame.Height);
//---- move our label to the top of the action sheet
lblActionSheetTitle.Frame = new RectangleF (10, 5, this.View.Frame.Width - 100, 35);
//---- move our button
btnDone.Frame = new RectangleF (actionSheetWidth - btnDoneWidth - 20, 5, btnDoneWidth, btnDoneHeight);
//actionSheet.SendSubviewToBack (this._lstPicker);
}
//========================================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20091027/7adbb6c2/attachment.html
More information about the MonoTouch
mailing list