Skip to content

Instantly share code, notes, and snippets.

@rid00z
Last active December 21, 2015 08:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rid00z/6275725 to your computer and use it in GitHub Desktop.
Save rid00z/6275725 to your computer and use it in GitHub Desktop.
ViewController that follows fingers.
public partial class FollowFingerViewController : UIViewController
{
static bool UserInterfaceIdiomIsPhone {
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}
UIView _square;
public FollowFingerViewController ()
{
_square = new UIView ();
_square.BackgroundColor = UIColor.Blue;
_square.Frame = new RectangleF (0, 0, 100, 100);
Add (_square);
}
public override void TouchesMoved (NSSet touches, UIEvent evt)
{
base.TouchesMoved (touches, evt);
UITouch touch = touches.AnyObject as UITouch;
var point = touch.LocationInView (View);
_square.Frame = new RectangleF(point, new SizeF(100,100));
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// Return true for supported orientations
if (UserInterfaceIdiomIsPhone) {
return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
} else {
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment