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 MyFrameLayout(this) { };
|
|
realViewGroup = viewGroup;
|
}
|
|
internal FrameLayout(UIView frameLayout)
|
{
|
viewGroup = frameLayout;
|
realViewGroup = viewGroup;
|
}
|
}
|
|
public class MyFrameLayout : UIView
|
{
|
[Weak] View view;
|
public MyFrameLayout(View view)
|
{
|
this.view = view;
|
//超出区域不显示
|
Layer.MasksToBounds = true;
|
}
|
|
|
/// <summary>
|
/// 点击开始
|
/// </summary>
|
/// <param name="touches">Touches.</param>
|
/// <param name="evt">Evt.</param>
|
public override void TouchesBegan(NSSet touches, UIEvent evt)
|
{
|
view?.TouchEvent(EventActions.Down, (touches.AnyObject as UITouch).LocationInView(this));
|
}
|
/// <summary>
|
/// 移动
|
/// </summary>
|
/// <param name="touches">Touches.</param>
|
/// <param name="evt">Evt.</param>
|
public override void TouchesMoved(NSSet touches, UIEvent evt)
|
{
|
view?.TouchEvent(EventActions.Move, (touches.AnyObject as UITouch).LocationInView(this));
|
}
|
|
/// <summary>
|
/// 点击弹起
|
/// </summary>
|
/// <param name="touches">Touches.</param>
|
/// <param name="evt">Evt.</param>
|
public override void TouchesEnded(NSSet touches, UIEvent evt)
|
{
|
view?.TouchEvent(EventActions.Up, (touches.AnyObject as UITouch).LocationInView(this));
|
}
|
|
public override void TouchesCancelled(NSSet touches, UIEvent evt)
|
{
|
view?.TouchEvent(EventActions.Cancel, (touches.AnyObject as UITouch).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);
|
}
|
}
|
}
|