using System; using UIKit; using Shared.IO; using CoreGraphics; using Foundation; namespace Shared { /// /// 绝对位置布局,已经全面检查 /// public class FrameLayout:ViewGroup { /// /// 绝对布局 /// 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; } /// /// 点击开始 /// /// Touches. /// Evt. public override void TouchesBegan(NSSet touches, UIEvent evt) { view?.TouchEvent(EventActions.Down, (touches.AnyObject as UITouch).LocationInView(this)); } /// /// 移动 /// /// Touches. /// Evt. public override void TouchesMoved(NSSet touches, UIEvent evt) { view?.TouchEvent(EventActions.Move, (touches.AnyObject as UITouch).LocationInView(this)); } /// /// 点击弹起 /// /// Touches. /// Evt. 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)); } /// /// 因为这个视图很奇怪,会自动加了两个UIImageView,所以这个特殊处理一下 /// /// View. public override void AddSubview(UIView view) { if (view.GetType() == typeof(UIImageView) && view.Tag != int.MinValue) { return; } base.AddSubview(view); } } }