wxr
2020-06-08 b71dfb3ca100340005d56e1298292807da82322d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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);
        }
    }
}