public override void ViewDidLoad() { base.ViewDidLoad(); using (image = UIImage.FromFile("monkeys.jpg")) { imageView = new UIImageView(new CGRect(new CGPoint(View.Center.X - image.Size.Width / 2, 0), image.Size)) { Image = image }; View.AddSubview(imageView); // 1. create the dynamic animator dynAnimator = new UIDynamicAnimator(this.View); // 2. create behavior(s) var dynItems = new IUIDynamicItem[] { imageView }; var gravity = new UIGravityBehavior(dynItems); var collision = new UICollisionBehavior(dynItems) { TranslatesReferenceBoundsIntoBoundary = true }; var dynBehavior = new UIDynamicItemBehavior(dynItems) { Elasticity = 0.7f }; // 3. add behaviors(s) to the dynamic animator dynAnimator.AddBehavior(gravity); dynAnimator.AddBehavior(collision); dynAnimator.AddBehavior(dynBehavior); } }
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); } }
public override void ViewDidLoad () { base.ViewDidLoad (); using (image = UIImage.FromFile ("monkeys.jpg")) { imageView = new UIImageView (new CGRect (new CGPoint (View.Center.X - image.Size.Width / 2, 0), image.Size)) { Image = image }; View.AddSubview (imageView); // 1. create the dynamic animator dynAnimator = new UIDynamicAnimator (this.View); // 2. create behavior(s) var dynItems = new IUIDynamicItem[] { imageView }; var gravity = new UIGravityBehavior (dynItems); var collision = new UICollisionBehavior (dynItems) { TranslatesReferenceBoundsIntoBoundary = true }; var dynBehavior = new UIDynamicItemBehavior (dynItems) { Elasticity = 0.7f }; // 3. add behaviors(s) to the dynamic animator dynAnimator.AddBehavior (gravity); dynAnimator.AddBehavior (collision); dynAnimator.AddBehavior (dynBehavior); } }
public VertexAttachmentBehaviour(IUIDynamicItem item, CGPoint anchorPoint) : base(item, anchorPoint) { }