using System;
|
using UIKit;
|
using Shared.IO;
|
using CoreGraphics;
|
using Foundation;
|
|
namespace Shared
|
{
|
/// <summary>
|
/// 绝对位置布局,已经全面检查
|
/// </summary>
|
public class FrameLayout:ViewGroup
|
{
|
/// <summary>
|
/// 绝对布局
|
/// </summary>
|
public FrameLayout()
|
{
|
viewGroup = new MyUIView(this);
|
realViewGroup = viewGroup;
|
}
|
|
internal FrameLayout(UIView frameLayout)
|
{
|
viewGroup = frameLayout;
|
realViewGroup = viewGroup;
|
}
|
}
|
|
public class MyUIView : UIView
|
{
|
View _view;
|
public MyUIView(View view)
|
{
|
//超出区域不显示
|
Layer.MasksToBounds = true;
|
_view = view;
|
}
|
|
/// <summary>
|
/// 点击开始
|
/// </summary>
|
/// <param name="touches">Touches.</param>
|
/// <param name="evt">Evt.</param>
|
public override void TouchesBegan(NSSet touches, UIEvent evt)
|
{
|
//base.TouchesBegan(touches, evt);
|
//System.Console.WriteLine("TouchesBegan" + BackgroundColor);
|
if (_view == null)
|
return;
|
UITouch touch = touches.AnyObject as UITouch;
|
_view.TouchEvent(EventActions.Down, touch.LocationInView(this));
|
//1109492162
|
}
|
/// <summary>
|
/// 移动
|
/// </summary>
|
/// <param name="touches">Touches.</param>
|
/// <param name="evt">Evt.</param>
|
public override void TouchesMoved(NSSet touches, UIEvent evt)
|
{
|
//base.TouchesMoved(touches, evt);
|
//System.Console.WriteLine("TouchesMoved" + BackgroundColor);
|
if (_view == null)
|
return;
|
UITouch touch = touches.AnyObject as UITouch;
|
_view.TouchEvent(EventActions.Move, touch.LocationInView(this));
|
|
}
|
|
/// <summary>
|
/// 点击弹起
|
/// </summary>
|
/// <param name="touches">Touches.</param>
|
/// <param name="evt">Evt.</param>
|
public override void TouchesEnded(NSSet touches, UIEvent evt)
|
{
|
//base.TouchesEnded(touches, evt);
|
//System.Console.WriteLine("TouchesEnded" + BackgroundColor);
|
if (_view == null)
|
return;
|
UITouch touch = touches.AnyObject as UITouch;
|
_view.TouchEvent(EventActions.Up, touch.LocationInView(this));
|
}
|
|
|
/// <summary>
|
/// 因为这个视图很奇怪,会自动加了两个UIImageView,所以这个特殊处理一下
|
/// </summary>
|
/// <param name="view">View.</param>
|
public override void AddSubview(UIView view)
|
{
|
if (view.GetType() == typeof(UIImageView) && view.Tag != int.MinValue)
|
{
|
return;
|
}
|
base.AddSubview(view);
|
}
|
}
|
}
|