Skip to content

Instantly share code, notes, and snippets.

View Splat's full-sized avatar

Ryan Donahue Splat

  • Earth
View GitHub Profile
@Splat
Splat / MonoTouch UITextField with DoneButton for NumberPad
Last active December 11, 2015 05:09
MonoTouch/iOS number pad keyboard needs a UIToolbar to include a button to resign the first responder of a UITextField because it doesn't include any built in way. This is a custom sub-classed UITextField which given a keyboard type that is a number pad will format a toolbar with a done button.
using System;
using MonoTouch.UIKit;
using System.Drawing;
public class CustomTextField : UITextField
{
public CustomTextField (UIKeyboardType keyboardType) {
// iPad doesn't really need it.
if (keyboardType == UIKeyboardType.NumberPad && DeviceHelper.IsIPhone()) {
UIToolbar numPadToolBar;
using System;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using MonoTouch.CoreGraphics;
public class SplatClearToolbar: UIToolbar
{
UIViewController vc;