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