Last active
December 21, 2016 12:52
-
-
Save andresbrun/ef038379ca2ce58a443f2147b0779c8c to your computer and use it in GitHub Desktop.
Shows the different ways to define a attachmentBehaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dragging an element with a PanGestureRecognizer for instance | |
let dragAttachmentBehaviour = UIAttachmentBehavior(item: targetView, | |
offsetFromCenter: offsetFromCenter, | |
attachedToAnchor: dragLocation) | |
// Attaching two box in a chain | |
let boxAttachmentBehaviour = UIAttachmentBehavior(item: box1, | |
offsetFromCenter: UIOffset(horizontal: 0, vertical: box1.bounds.midY), | |
attachedTo: box2, | |
offsetFromCenter: UIOffset(horizontal: 0, vertical: -box2.bounds.midY)) | |
// NOTE: all offsetFromCenter are optional. They are the center of the view by default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment