本文整理汇总了C#中UITapGestureRecognizer.LocationOfTouch方法的典型用法代码示例。如果您正苦于以下问题:C# UITapGestureRecognizer.LocationOfTouch方法的具体用法?C# UITapGestureRecognizer.LocationOfTouch怎么用?C# UITapGestureRecognizer.LocationOfTouch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITapGestureRecognizer
的用法示例。
在下文中一共展示了UITapGestureRecognizer.LocationOfTouch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
View.BackgroundColor = UIColor.White;
View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
// Adjust taps/touches required to fit your needs.
UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer() {
NumberOfTapsRequired = 1,
NumberOfTouchesRequired = 1,
};
tapRecognizer.AddTarget((sender) => {
// The foreach is only necessary if you have more than one touch for your recognizer.
// For all else just roll with zero, `PointF location = tapRecognizer.LocationOfTouch(0, View);`
foreach (int locationIndex in Enumerable.Range(0, tapRecognizer.NumberOfTouches)) {
PointF location = tapRecognizer.LocationOfTouch(locationIndex, View);
UIView newTapView = new UIView(new RectangleF(PointF.Empty, ItemSize)) {
BackgroundColor = GetRandomColor(),
};
newTapView.Center = location;
View.Add(newTapView);
// Remove the view after it's been around a while.
Task.Delay(5000).ContinueWith(_ => InvokeOnMainThread(() => {
newTapView.RemoveFromSuperview();
newTapView.Dispose();
}));
}
});
View.AddGestureRecognizer(tapRecognizer);
}
示例2: WireUpTapGestureRecognizer
protected void WireUpTapGestureRecognizer ()
{
// create a new tap gesture
UITapGestureRecognizer tapGesture = new UITapGestureRecognizer ();
// wire up the event handler (have to use a selector)
tapGesture.AddTarget ( () => {
lblGestureStatus.Text = "tap me image tapped @" + tapGesture.LocationOfTouch (0, imgTapMe).ToString ();
});
// configure it
tapGesture.NumberOfTapsRequired = 2;
// add the gesture recognizer to the view
imgTapMe.AddGestureRecognizer (tapGesture);
}
示例3: OnTapOutside
private void OnTapOutside(UITapGestureRecognizer recogniser)
{
if (recogniser.State == UIGestureRecognizerState.Ended)
{
var window = View.Window;
var viewLoc = recogniser.LocationOfTouch (0, View);
var width = _parent.View.Frame.Width * 3/4;
//var height = _parent.View.Frame.Height - 65;
//if (!this.View.PointInside (viewLoc, null)) {
if (viewLoc.X > width) {
DismissViewController (true, () => window.RemoveGestureRecognizer (_dismissRecognizer));
}
}
}
示例4: AddTag
void AddTag(UITapGestureRecognizer gestureRecognizer)
{
Console.WriteLine ("addsubtag()");
UIAlertView av = new UIAlertView ("input tags, comma seperated", "\n", null, "Cancel", new string[] {"Create"});
Console.WriteLine(gestureRecognizer.LocationOfTouch (0, tlv));
av.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
av.Clicked += (object sender, UIButtonEventArgs e) => {
String tagText = av.GetTextField (0).Text;
saveTagText (tagText);
};
av.Show();
}