Exemplo n.º 1
0
        public StickyCornersBehavior(IUIDynamicItem stickyCornerItem, float stickyCornerInset)
        {
            item        = stickyCornerItem;
            cornerInset = stickyCornerInset;

            fieldBehaviors = new List <UIFieldBehavior> ();

            collisionBehavior = new UICollisionBehavior(item)
            {
                TranslatesReferenceBoundsIntoBoundary = true
            };

            itemBehavior = new UIDynamicItemBehavior(item)
            {
                Density        = 0.01f,
                Resistance     = 10f,
                Friction       = 0f,
                AllowsRotation = false
            };

            AddChildBehavior(collisionBehavior);
            AddChildBehavior(itemBehavior);

            for (int i = 0; i <= 3; i++)
            {
                var fieldBehavior = UIFieldBehavior.CreateSpringField();
                fieldBehavior.AddItem(item);
                fieldBehaviors.Add(fieldBehavior);
                AddChildBehavior(fieldBehavior);
            }
        }
Exemplo n.º 2
0
 void UpdateFieldBehaviour(UIFieldBehavior fieldBehaviour, CGPoint point, CGRect regionRect)
 {
     fieldBehaviour.Position = new CGPoint(point);
     fieldBehaviour.Region   = new UIRegion(new CGSize(regionRect.Width / 2f - regionRect.X, regionRect.Height / 2f - regionRect.Y));
 }