Skip to content

Instantly share code, notes, and snippets.

@tp
Forked from dalexsoto/MojoElement.cs
Created March 10, 2012 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tp/2012387 to your computer and use it in GitHub Desktop.
Save tp/2012387 to your computer and use it in GitHub Desktop.
RightAlignedEntryElement: A right aligned EntryElement for MonoTouch.Dialog
/// <summary>
/// A right aligned MonoTouch.Dialog EntryElement to use and build upon
///
/// @tp on github, 2012
/// </summary>
using System.Drawing;
using MonoTouch.Dialog;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Controls
{
public class RightAlignedEntryElement : EntryElement
{
private NSString _cellKey = new NSString("RightAlignedEntryElement");
public RightAlignedEntryElement (string caption) : base(caption, null, null)
{
}
protected override UITextField CreateTextField(RectangleF frame)
{
var textField = base.CreateTextField (frame);
textField.TextAlignment = UITextAlignment.Right;
// shrink textfield a little to have some nice border
textField.Frame = new RectangleF(new PointF(textField.Frame.Location.X, textField.Frame.Location.Y), new SizeF(textField.Frame.Size.Width - 10, textField.Frame.Size.Height));
return textField;
}
public override UITableViewCell GetCell(UITableView tv)
{
var cell = base.GetCell (tv);
return cell;
}
protected override NSString CellKey {
get {
return _cellKey;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment