Last active
December 21, 2015 08:08
-
-
Save rid00z/6275725 to your computer and use it in GitHub Desktop.
ViewController that follows fingers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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