├── .DS_Store ├── DragDropCollectionView.swift ├── README.md ├── Sample Project ├── .DS_Store ├── DragDrop.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ ├── Lior.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── prog.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── Lior.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ ├── DragDrop.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── prog.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── DragDrop │ ├── .DS_Store │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift └── DragDropTests │ ├── DragDropTests.swift │ └── Info.plist └── demo.gif /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lior539/DragDropCollectionView/5d1d3ef8d82f18b61c023025a1411ecbe84a8bd1/.DS_Store -------------------------------------------------------------------------------- /DragDropCollectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DragDropCollectionView.swift 3 | // DragDrop 4 | // 5 | // Created by Lior Neu-ner on 2014/12/30. 6 | // Copyright (c) 2014 LiorN. All rights reserved. 7 | // 3rd test for git submodule 8 | 9 | //Just testing git subtree for the second time 10 | import UIKit 11 | 12 | @objc protocol DrapDropCollectionViewDelegate { 13 | func dragDropCollectionViewDidMoveCellFromInitialIndexPath(_ initialIndexPath: IndexPath, toNewIndexPath newIndexPath: IndexPath) 14 | @objc optional func dragDropCollectionViewDraggingDidBeginWithCellAtIndexPath(_ indexPath: IndexPath) 15 | @objc optional func dragDropCollectionViewDraggingDidEndForCellAtIndexPath(_ indexPath: IndexPath) 16 | } 17 | 18 | class DragDropCollectionView: UICollectionView, UIGestureRecognizerDelegate { 19 | weak var draggingDelegate: DrapDropCollectionViewDelegate? 20 | 21 | var longPressRecognizer: UILongPressGestureRecognizer = { 22 | let longPressRecognizer = UILongPressGestureRecognizer() 23 | longPressRecognizer.delaysTouchesBegan = false 24 | longPressRecognizer.cancelsTouchesInView = false 25 | longPressRecognizer.numberOfTouchesRequired = 1 26 | longPressRecognizer.minimumPressDuration = 0.1 27 | longPressRecognizer.allowableMovement = 10.0 28 | return longPressRecognizer 29 | }() 30 | 31 | fileprivate var draggedCellIndexPath: IndexPath? 32 | var draggingView: UIView? 33 | fileprivate var touchOffsetFromCenterOfCell: CGPoint? 34 | var isWiggling = false 35 | fileprivate let pingInterval = 0.3 36 | var isAutoScrolling = false 37 | 38 | override var intrinsicContentSize: CGSize { 39 | self.layoutIfNeeded() 40 | return CGSize(width: UIView.noIntrinsicMetric, height: self.contentSize.height) 41 | } 42 | 43 | required init?(coder aDecoder: NSCoder) { 44 | super.init(coder: aDecoder) 45 | commonInit() 46 | } 47 | 48 | override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { 49 | super.init(frame: frame, collectionViewLayout: layout) 50 | commonInit() 51 | } 52 | 53 | fileprivate func commonInit() { 54 | longPressRecognizer.addTarget(self, action: #selector(DragDropCollectionView.handleLongPress(_:))) 55 | longPressRecognizer.isEnabled = false 56 | self.addGestureRecognizer(longPressRecognizer) 57 | 58 | } 59 | 60 | override func reloadData() { 61 | super.reloadData() 62 | self.invalidateIntrinsicContentSize() 63 | } 64 | 65 | @objc func handleLongPress(_ longPressRecognizer: UILongPressGestureRecognizer) { 66 | let touchLocation = longPressRecognizer.location(in: self) 67 | 68 | switch (longPressRecognizer.state) { 69 | case UIGestureRecognizerState.began: 70 | draggedCellIndexPath = self.indexPathForItem(at: touchLocation) 71 | if (draggedCellIndexPath != nil) { 72 | draggingDelegate?.dragDropCollectionViewDraggingDidBeginWithCellAtIndexPath?(draggedCellIndexPath!) 73 | let draggedCell = self.cellForItem(at: draggedCellIndexPath! as IndexPath) as UICollectionViewCell? 74 | draggingView = UIImageView(image: getRasterizedImageCopyOfCell(draggedCell!)) 75 | draggingView!.center = (draggedCell!.center) 76 | self.addSubview(draggingView!) 77 | draggedCell!.alpha = 0.0 78 | touchOffsetFromCenterOfCell = CGPoint(x: draggedCell!.center.x - touchLocation.x, y: draggedCell!.center.y - touchLocation.y) 79 | UIView.animate(withDuration: 0.4, animations: { () -> Void in 80 | self.draggingView!.transform = CGAffineTransform(scaleX: 1.3, y: 1.3) 81 | self.draggingView!.alpha = 0.8 82 | }) 83 | } 84 | 85 | case UIGestureRecognizerState.changed: 86 | if draggedCellIndexPath != nil { 87 | draggingView!.center = CGPoint(x: touchLocation.x + touchOffsetFromCenterOfCell!.x, y: touchLocation.y + touchOffsetFromCenterOfCell!.y) 88 | 89 | if !isAutoScrolling { 90 | 91 | dispatchOnMainQueueAfter(pingInterval, closure: { () -> () in 92 | let scroller = self.shouldAutoScroll(touchLocation) 93 | if (scroller.shouldScroll) { 94 | self.autoScroll(scroller.direction) 95 | self.isAutoScrolling = true 96 | } 97 | }) 98 | } 99 | 100 | dispatchOnMainQueueAfter(pingInterval, closure: { () -> () in 101 | let shouldSwapCellsTuple = self.shouldSwapCells(touchLocation) 102 | if shouldSwapCellsTuple.shouldSwap { 103 | self.swapDraggedCellWithCellAtIndexPath(shouldSwapCellsTuple.newIndexPath!) 104 | } 105 | }) 106 | } 107 | case UIGestureRecognizerState.ended: 108 | if draggedCellIndexPath != nil { 109 | draggingDelegate?.dragDropCollectionViewDraggingDidEndForCellAtIndexPath?(draggedCellIndexPath!) 110 | let draggedCell = self.cellForItem(at: draggedCellIndexPath! as IndexPath) 111 | UIView.animate(withDuration: 0.4, animations: { () -> Void in 112 | self.draggingView!.transform = CGAffineTransform.identity 113 | self.draggingView!.alpha = 1.0 114 | if (draggedCell != nil) { 115 | self.draggingView!.center = draggedCell!.center 116 | } 117 | }, completion: { (finished) -> Void in 118 | self.draggingView!.removeFromSuperview() 119 | self.draggingView = nil 120 | draggedCell?.alpha = 1.0 121 | self.draggedCellIndexPath = nil 122 | }) 123 | } 124 | default: () 125 | } 126 | } 127 | 128 | 129 | func enableDragging(_ enable: Bool) { 130 | if enable { 131 | longPressRecognizer.isEnabled = true 132 | } else { 133 | longPressRecognizer.isEnabled = false 134 | } 135 | } 136 | 137 | fileprivate func shouldSwapCells(_ previousTouchLocation: CGPoint) -> (shouldSwap: Bool, newIndexPath: IndexPath?) { 138 | var shouldSwap = false 139 | var newIndexPath: IndexPath? 140 | let currentTouchLocation = self.longPressRecognizer.location(in: self) 141 | if !Double(currentTouchLocation.x).isNaN && !Double(currentTouchLocation.y).isNaN { 142 | if distanceBetweenPoints(previousTouchLocation, secondPoint: currentTouchLocation) < CGFloat(20.0) { 143 | if let newIndexPathForCell = self.indexPathForItem(at: currentTouchLocation) { 144 | if newIndexPathForCell != self.draggedCellIndexPath! as IndexPath { 145 | shouldSwap = true 146 | newIndexPath = newIndexPathForCell 147 | } 148 | } 149 | } 150 | } 151 | return (shouldSwap, newIndexPath) 152 | } 153 | 154 | fileprivate func swapDraggedCellWithCellAtIndexPath(_ newIndexPath: IndexPath) { 155 | self.moveItem(at: self.draggedCellIndexPath! as IndexPath, to: newIndexPath as IndexPath) 156 | let draggedCell = self.cellForItem(at: newIndexPath as IndexPath)! 157 | draggedCell.alpha = 0 158 | self.draggingDelegate?.dragDropCollectionViewDidMoveCellFromInitialIndexPath(self.draggedCellIndexPath!, toNewIndexPath: newIndexPath) 159 | self.draggedCellIndexPath = newIndexPath 160 | } 161 | 162 | 163 | } 164 | 165 | //AutoScroll 166 | extension DragDropCollectionView { 167 | enum AutoScrollDirection: Int { 168 | case invalid = 0 169 | case towardsOrigin = 1 170 | case awayFromOrigin = 2 171 | } 172 | 173 | func autoScroll(_ direction: AutoScrollDirection) { 174 | let currentLongPressTouchLocation = self.longPressRecognizer.location(in: self) 175 | var increment: CGFloat 176 | var newContentOffset: CGPoint 177 | if (direction == AutoScrollDirection.towardsOrigin) { 178 | increment = -50.0 179 | } else { 180 | increment = 50.0 181 | } 182 | newContentOffset = CGPoint(x: self.contentOffset.x, y: self.contentOffset.y + increment) 183 | let flowLayout = self.collectionViewLayout as! UICollectionViewFlowLayout 184 | if flowLayout.scrollDirection == UICollectionView.ScrollDirection.horizontal{ 185 | newContentOffset = CGPoint(x: self.contentOffset.x + increment, y: self.contentOffset.y) 186 | } 187 | if ((direction == AutoScrollDirection.towardsOrigin && newContentOffset.y < 0) || (direction == AutoScrollDirection.awayFromOrigin && newContentOffset.y > self.contentSize.height - self.frame.height)) { 188 | dispatchOnMainQueueAfter(0.3, closure: { () -> () in 189 | self.isAutoScrolling = false 190 | }) 191 | } else { 192 | UIView.animate(withDuration: 0.3 193 | , delay: 0.0 194 | , options: UIView.AnimationOptions.curveLinear 195 | , animations: { () -> Void in 196 | self.setContentOffset(newContentOffset, animated: false) 197 | if (self.draggingView != nil) { 198 | if flowLayout.scrollDirection == UICollectionView.ScrollDirection.vertical{ 199 | var draggingFrame = self.draggingView!.frame 200 | draggingFrame.origin.y += increment 201 | self.draggingView!.frame = draggingFrame 202 | }else{ 203 | var draggingFrame = self.draggingView!.frame 204 | draggingFrame.origin.x += increment 205 | self.draggingView!.frame = draggingFrame 206 | } 207 | } 208 | }) { (finished) -> Void in 209 | dispatchOnMainQueueAfter(0.0, closure: { () -> () in 210 | var updatedTouchLocationWithNewOffset = CGPoint(x: currentLongPressTouchLocation.x, y: currentLongPressTouchLocation.y + increment) 211 | if flowLayout.scrollDirection == UICollectionView.ScrollDirection.horizontal{ 212 | updatedTouchLocationWithNewOffset = CGPoint(x: currentLongPressTouchLocation.x + increment, y: currentLongPressTouchLocation.y) 213 | } 214 | let scroller = self.shouldAutoScroll(updatedTouchLocationWithNewOffset) 215 | if scroller.shouldScroll { 216 | self.autoScroll(scroller.direction) 217 | } else { 218 | self.isAutoScrolling = false 219 | } 220 | }) 221 | } 222 | } 223 | } 224 | 225 | func shouldAutoScroll(_ previousTouchLocation: CGPoint) -> (shouldScroll: Bool, direction: AutoScrollDirection) { 226 | let previousTouchLocation = self.convert(previousTouchLocation, to: self.superview) 227 | let currentTouchLocation = self.longPressRecognizer.location(in: self.superview) 228 | 229 | if let flowLayout = self.collectionViewLayout as? UICollectionViewFlowLayout { 230 | if !Double(currentTouchLocation.x).isNaN && !Double(currentTouchLocation.y).isNaN { 231 | if distanceBetweenPoints(previousTouchLocation, secondPoint: currentTouchLocation) < CGFloat(20.0) { 232 | let scrollDirection = flowLayout.scrollDirection 233 | var scrollBoundsSize: CGSize 234 | let scrollBoundsLength: CGFloat = 50.0 235 | var scrollRectAtEnd: CGRect 236 | switch scrollDirection { 237 | case UICollectionViewScrollDirection.horizontal: 238 | scrollBoundsSize = CGSize(width: scrollBoundsLength, height: self.frame.height) 239 | scrollRectAtEnd = CGRect(x: self.frame.origin.x + self.frame.width - scrollBoundsSize.width , y: self.frame.origin.y, width: scrollBoundsSize.width, height: self.frame.height) 240 | case UICollectionViewScrollDirection.vertical: 241 | scrollBoundsSize = CGSize(width: self.frame.width, height: scrollBoundsLength) 242 | scrollRectAtEnd = CGRect(x: self.frame.origin.x, y: self.frame.origin.y + self.frame.height - scrollBoundsSize.height, width: self.frame.width, height: scrollBoundsSize.height) 243 | } 244 | let scrollRectAtOrigin = CGRect(origin: self.frame.origin, size: scrollBoundsSize) 245 | if scrollRectAtOrigin.contains(currentTouchLocation) { 246 | return (true, AutoScrollDirection.towardsOrigin) 247 | } else if scrollRectAtEnd.contains(currentTouchLocation) { 248 | return (true, AutoScrollDirection.awayFromOrigin) 249 | } 250 | } 251 | } 252 | } 253 | return (false, AutoScrollDirection.invalid) 254 | } 255 | } 256 | 257 | //Wiggle Animation 258 | extension DragDropCollectionView { 259 | func startWiggle() { 260 | 261 | for cell in visibleCells { 262 | addWiggleAnimationTo(cell ) 263 | } 264 | isWiggling = true 265 | } 266 | 267 | func stopWiggle() { 268 | for cell in visibleCells { 269 | cell.layer.removeAllAnimations() 270 | } 271 | isWiggling = false 272 | } 273 | 274 | override func dequeueReusableCell(withReuseIdentifier identifier: String, for indexPath: IndexPath) -> UICollectionViewCell { 275 | let cell: AnyObject = super.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) 276 | if isWiggling { 277 | addWiggleAnimationTo(cell as! UICollectionViewCell) 278 | } else { 279 | cell.layer.removeAllAnimations() 280 | } 281 | return cell as! UICollectionViewCell 282 | } 283 | 284 | func addWiggleAnimationTo(_ cell: UICollectionViewCell) { 285 | CATransaction.begin() 286 | CATransaction.setDisableActions(false) 287 | cell.layer.add(rotationAnimation(), forKey: "rotation") 288 | 289 | cell.layer.add(bounceAnimation(), forKey: "bounce") 290 | 291 | CATransaction.commit() 292 | 293 | } 294 | 295 | fileprivate func rotationAnimation() -> CAKeyframeAnimation { 296 | 297 | let animation = CAKeyframeAnimation(keyPath: "transform.rotation.z") 298 | let angle = CGFloat(0.04) 299 | let duration = TimeInterval(0.1) 300 | let variance = Double(0.025) 301 | animation.values = [angle, -angle] 302 | animation.autoreverses = true 303 | animation.duration = self.randomize(duration, withVariance: variance) 304 | animation.repeatCount = Float.infinity 305 | return animation 306 | 307 | } 308 | 309 | fileprivate func bounceAnimation() -> CAKeyframeAnimation { 310 | let animation = CAKeyframeAnimation(keyPath: "transform.translation.y") 311 | let bounce = CGFloat(3.0) 312 | let duration = TimeInterval(0.12) 313 | let variance = Double(0.025) 314 | animation.values = [bounce, -bounce] 315 | animation.autoreverses = true 316 | animation.duration = self.randomize(duration, withVariance: variance) 317 | animation.repeatCount = Float.infinity 318 | return animation 319 | 320 | } 321 | 322 | fileprivate func randomize(_ interval: TimeInterval, withVariance variance:Double) -> TimeInterval { 323 | 324 | let random = (Double(arc4random_uniform(1000)) - 500.0) / 500.0 325 | return interval + variance * random; 326 | } 327 | } 328 | 329 | //Assisting Functions 330 | extension DragDropCollectionView { 331 | func getRasterizedImageCopyOfCell(_ cell: UICollectionViewCell) -> UIImage { 332 | UIGraphicsBeginImageContextWithOptions(cell.bounds.size, false, 0.0) 333 | cell.layer.render(in: UIGraphicsGetCurrentContext()!) 334 | let image = UIGraphicsGetImageFromCurrentImageContext() 335 | UIGraphicsEndImageContext() 336 | return image! 337 | } 338 | 339 | } 340 | 341 | public func dispatchOnMainQueueAfter(_ delay:Double, closure:@escaping ()->Void) { 342 | DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+delay, qos: DispatchQoS.userInteractive, flags: DispatchWorkItemFlags.enforceQoS, execute: closure) 343 | } 344 | 345 | public func distanceBetweenPoints(_ firstPoint: CGPoint, secondPoint: CGPoint) -> CGFloat { 346 | let xDistance = firstPoint.x - secondPoint.x 347 | let yDistance = firstPoint.y - secondPoint.y 348 | return sqrt(xDistance * xDistance + yDistance * yDistance) 349 | } 350 | 351 | 352 | 353 | 354 | 355 | 356 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DragDropCollectionView 2 | A UICollectionView which allows for easy drag and drop to reorder cells. Mimicks the drag and drop on the iOS Springboard when reordering apps (wiggle animation included!). 3 | 4 | I have also included automatic scrolling for when the collection view's content does not all fit in the frame 5 | 6 | ![Alt text](/demo.gif) 7 | 8 | Installation 9 | -------------- 10 | 11 | To use the DragDropCollectionView class in an app, just drag the DragDropCollectionView.swift file into your project. 12 | 13 | Protocols and Delegates 14 | -------------- 15 | DragDropCollectionView has the following protocol: 16 | 17 | ```` 18 | @objc protocol DrapDropCollectionViewDelegate: UICollectionViewDelegate 19 | ```` 20 | 21 | This inherits from UICollectionViewDelegate and is to be used in place of the '.delegate' property found in UICollectionView 22 | 23 | DragDropCollectionView has the following delegate: 24 | 25 | ```` 26 | weak var draggingDelegate: DrapDropCollectionViewDelegate? 27 | ```` 28 | 29 | The DragDropCollectionViewDelegate has the following required methods: 30 | 31 | ```` 32 | func dragDropCollectionViewDidMoveCellFromInitialIndexPath(initialIndexPath: NSIndexPath, toNewIndexPath newIndexPath: NSIndexPath) 33 | ```` 34 | 35 | This method should be used in your to 'swap' items in your datasource 36 | 37 | The DragDropCollectionViewDelegate has the following optional methods: 38 | 39 | ```` 40 | optional func dragDropCollectionViewDraggingDidBeginWithCellAtIndexPath(indexPath: NSIndexPath) 41 | optional func dragDropCollectionViewDraggingDidEndForCellAtIndexPath(indexPath: NSIndexPath) 42 | ```` 43 | 44 | 45 | Methods 46 | -------------- 47 | Dragging can be easily enabled and disabled using the follwing method: 48 | ```` 49 | func enableDragging(enable: Bool) 50 | ```` 51 | 52 | To start the wiggle animation, use: 53 | 54 | ```` 55 | func startWiggle() 56 | ```` 57 | 58 | To stop the wiggle animation, use: 59 | 60 | ```` 61 | func stopWiggle() 62 | ```` 63 | -------------------------------------------------------------------------------- /Sample Project/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lior539/DragDropCollectionView/5d1d3ef8d82f18b61c023025a1411ecbe84a8bd1/Sample Project/.DS_Store -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BA18A7C21A649C8D0044B197 /* DragDropCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA18A7C11A649C8D0044B197 /* DragDropCollectionView.swift */; }; 11 | BA6E6D401A529CAE0005985D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA6E6D3F1A529CAE0005985D /* AppDelegate.swift */; }; 12 | BA6E6D421A529CAF0005985D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA6E6D411A529CAF0005985D /* ViewController.swift */; }; 13 | BA6E6D451A529CAF0005985D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BA6E6D431A529CAF0005985D /* Main.storyboard */; }; 14 | BA6E6D471A529CB00005985D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA6E6D461A529CB00005985D /* Images.xcassets */; }; 15 | BA6E6D4A1A529CB00005985D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = BA6E6D481A529CB00005985D /* LaunchScreen.xib */; }; 16 | BA6E6D561A529CB20005985D /* DragDropTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA6E6D551A529CB20005985D /* DragDropTests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | BA6E6D501A529CB10005985D /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = BA6E6D321A529CAC0005985D /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = BA6E6D391A529CAD0005985D; 25 | remoteInfo = DragDrop; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | BA18A7C11A649C8D0044B197 /* DragDropCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DragDropCollectionView.swift; path = ../../DragDropCollectionView.swift; sourceTree = ""; }; 31 | BA6E6D3A1A529CAD0005985D /* DragDrop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DragDrop.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | BA6E6D3E1A529CAD0005985D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | BA6E6D3F1A529CAE0005985D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | BA6E6D411A529CAF0005985D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 35 | BA6E6D441A529CAF0005985D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | BA6E6D461A529CB00005985D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | BA6E6D491A529CB00005985D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 38 | BA6E6D4F1A529CB10005985D /* DragDropTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DragDropTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | BA6E6D541A529CB10005985D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | BA6E6D551A529CB20005985D /* DragDropTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DragDropTests.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | BA6E6D371A529CAD0005985D /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | BA6E6D4C1A529CB10005985D /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | BA6E6D311A529CAC0005985D = { 62 | isa = PBXGroup; 63 | children = ( 64 | BA6E6D3C1A529CAD0005985D /* DragDrop */, 65 | BA6E6D521A529CB10005985D /* DragDropTests */, 66 | BA6E6D3B1A529CAD0005985D /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | BA6E6D3B1A529CAD0005985D /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | BA6E6D3A1A529CAD0005985D /* DragDrop.app */, 74 | BA6E6D4F1A529CB10005985D /* DragDropTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | BA6E6D3C1A529CAD0005985D /* DragDrop */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | BA6E6D3F1A529CAE0005985D /* AppDelegate.swift */, 83 | BA6E6D411A529CAF0005985D /* ViewController.swift */, 84 | BA18A7C11A649C8D0044B197 /* DragDropCollectionView.swift */, 85 | BA6E6D431A529CAF0005985D /* Main.storyboard */, 86 | BA6E6D461A529CB00005985D /* Images.xcassets */, 87 | BA6E6D481A529CB00005985D /* LaunchScreen.xib */, 88 | BA6E6D3D1A529CAD0005985D /* Supporting Files */, 89 | ); 90 | path = DragDrop; 91 | sourceTree = ""; 92 | }; 93 | BA6E6D3D1A529CAD0005985D /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | BA6E6D3E1A529CAD0005985D /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | BA6E6D521A529CB10005985D /* DragDropTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | BA6E6D551A529CB20005985D /* DragDropTests.swift */, 105 | BA6E6D531A529CB10005985D /* Supporting Files */, 106 | ); 107 | path = DragDropTests; 108 | sourceTree = ""; 109 | }; 110 | BA6E6D531A529CB10005985D /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | BA6E6D541A529CB10005985D /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | BA6E6D391A529CAD0005985D /* DragDrop */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = BA6E6D591A529CB20005985D /* Build configuration list for PBXNativeTarget "DragDrop" */; 124 | buildPhases = ( 125 | BA6E6D361A529CAD0005985D /* Sources */, 126 | BA6E6D371A529CAD0005985D /* Frameworks */, 127 | BA6E6D381A529CAD0005985D /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = DragDrop; 134 | productName = DragDrop; 135 | productReference = BA6E6D3A1A529CAD0005985D /* DragDrop.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | BA6E6D4E1A529CB10005985D /* DragDropTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = BA6E6D5C1A529CB20005985D /* Build configuration list for PBXNativeTarget "DragDropTests" */; 141 | buildPhases = ( 142 | BA6E6D4B1A529CB10005985D /* Sources */, 143 | BA6E6D4C1A529CB10005985D /* Frameworks */, 144 | BA6E6D4D1A529CB10005985D /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | BA6E6D511A529CB10005985D /* PBXTargetDependency */, 150 | ); 151 | name = DragDropTests; 152 | productName = DragDropTests; 153 | productReference = BA6E6D4F1A529CB10005985D /* DragDropTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | BA6E6D321A529CAC0005985D /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastUpgradeCheck = 1020; 163 | ORGANIZATIONNAME = LiorN; 164 | TargetAttributes = { 165 | BA6E6D391A529CAD0005985D = { 166 | CreatedOnToolsVersion = 6.1.1; 167 | DevelopmentTeam = AS8F5Z84GP; 168 | }; 169 | BA6E6D4E1A529CB10005985D = { 170 | CreatedOnToolsVersion = 6.1.1; 171 | TestTargetID = BA6E6D391A529CAD0005985D; 172 | }; 173 | }; 174 | }; 175 | buildConfigurationList = BA6E6D351A529CAC0005985D /* Build configuration list for PBXProject "DragDrop" */; 176 | compatibilityVersion = "Xcode 3.2"; 177 | developmentRegion = English; 178 | hasScannedForEncodings = 0; 179 | knownRegions = ( 180 | English, 181 | en, 182 | Base, 183 | ); 184 | mainGroup = BA6E6D311A529CAC0005985D; 185 | productRefGroup = BA6E6D3B1A529CAD0005985D /* Products */; 186 | projectDirPath = ""; 187 | projectRoot = ""; 188 | targets = ( 189 | BA6E6D391A529CAD0005985D /* DragDrop */, 190 | BA6E6D4E1A529CB10005985D /* DragDropTests */, 191 | ); 192 | }; 193 | /* End PBXProject section */ 194 | 195 | /* Begin PBXResourcesBuildPhase section */ 196 | BA6E6D381A529CAD0005985D /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | BA6E6D451A529CAF0005985D /* Main.storyboard in Resources */, 201 | BA6E6D4A1A529CB00005985D /* LaunchScreen.xib in Resources */, 202 | BA6E6D471A529CB00005985D /* Images.xcassets in Resources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | BA6E6D4D1A529CB10005985D /* Resources */ = { 207 | isa = PBXResourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXResourcesBuildPhase section */ 214 | 215 | /* Begin PBXSourcesBuildPhase section */ 216 | BA6E6D361A529CAD0005985D /* Sources */ = { 217 | isa = PBXSourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | BA6E6D421A529CAF0005985D /* ViewController.swift in Sources */, 221 | BA18A7C21A649C8D0044B197 /* DragDropCollectionView.swift in Sources */, 222 | BA6E6D401A529CAE0005985D /* AppDelegate.swift in Sources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | BA6E6D4B1A529CB10005985D /* Sources */ = { 227 | isa = PBXSourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | BA6E6D561A529CB20005985D /* DragDropTests.swift in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXSourcesBuildPhase section */ 235 | 236 | /* Begin PBXTargetDependency section */ 237 | BA6E6D511A529CB10005985D /* PBXTargetDependency */ = { 238 | isa = PBXTargetDependency; 239 | target = BA6E6D391A529CAD0005985D /* DragDrop */; 240 | targetProxy = BA6E6D501A529CB10005985D /* PBXContainerItemProxy */; 241 | }; 242 | /* End PBXTargetDependency section */ 243 | 244 | /* Begin PBXVariantGroup section */ 245 | BA6E6D431A529CAF0005985D /* Main.storyboard */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | BA6E6D441A529CAF0005985D /* Base */, 249 | ); 250 | name = Main.storyboard; 251 | sourceTree = ""; 252 | }; 253 | BA6E6D481A529CB00005985D /* LaunchScreen.xib */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | BA6E6D491A529CB00005985D /* Base */, 257 | ); 258 | name = LaunchScreen.xib; 259 | sourceTree = ""; 260 | }; 261 | /* End PBXVariantGroup section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | BA6E6D571A529CB20005985D /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 270 | CLANG_CXX_LIBRARY = "libc++"; 271 | CLANG_ENABLE_MODULES = YES; 272 | CLANG_ENABLE_OBJC_ARC = YES; 273 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_COMMA = YES; 276 | CLANG_WARN_CONSTANT_CONVERSION = YES; 277 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 279 | CLANG_WARN_EMPTY_BODY = YES; 280 | CLANG_WARN_ENUM_CONVERSION = YES; 281 | CLANG_WARN_INFINITE_RECURSION = YES; 282 | CLANG_WARN_INT_CONVERSION = YES; 283 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 284 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 285 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 288 | CLANG_WARN_STRICT_PROTOTYPES = YES; 289 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 290 | CLANG_WARN_UNREACHABLE_CODE = YES; 291 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 292 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 293 | COPY_PHASE_STRIP = NO; 294 | ENABLE_STRICT_OBJC_MSGSEND = YES; 295 | ENABLE_TESTABILITY = YES; 296 | GCC_C_LANGUAGE_STANDARD = gnu99; 297 | GCC_DYNAMIC_NO_PIC = NO; 298 | GCC_NO_COMMON_BLOCKS = YES; 299 | GCC_OPTIMIZATION_LEVEL = 0; 300 | GCC_PREPROCESSOR_DEFINITIONS = ( 301 | "DEBUG=1", 302 | "$(inherited)", 303 | ); 304 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 305 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 306 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 307 | GCC_WARN_UNDECLARED_SELECTOR = YES; 308 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 309 | GCC_WARN_UNUSED_FUNCTION = YES; 310 | GCC_WARN_UNUSED_VARIABLE = YES; 311 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 312 | MTL_ENABLE_DEBUG_INFO = YES; 313 | ONLY_ACTIVE_ARCH = YES; 314 | SDKROOT = iphoneos; 315 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 316 | TARGETED_DEVICE_FAMILY = "1,2"; 317 | }; 318 | name = Debug; 319 | }; 320 | BA6E6D581A529CB20005985D /* Release */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 330 | CLANG_WARN_BOOL_CONVERSION = YES; 331 | CLANG_WARN_COMMA = YES; 332 | CLANG_WARN_CONSTANT_CONVERSION = YES; 333 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INFINITE_RECURSION = YES; 338 | CLANG_WARN_INT_CONVERSION = YES; 339 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 341 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 343 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 344 | CLANG_WARN_STRICT_PROTOTYPES = YES; 345 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 346 | CLANG_WARN_UNREACHABLE_CODE = YES; 347 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 348 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 349 | COPY_PHASE_STRIP = YES; 350 | ENABLE_NS_ASSERTIONS = NO; 351 | ENABLE_STRICT_OBJC_MSGSEND = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_NO_COMMON_BLOCKS = YES; 354 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 355 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 356 | GCC_WARN_UNDECLARED_SELECTOR = YES; 357 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 358 | GCC_WARN_UNUSED_FUNCTION = YES; 359 | GCC_WARN_UNUSED_VARIABLE = YES; 360 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 361 | MTL_ENABLE_DEBUG_INFO = NO; 362 | SDKROOT = iphoneos; 363 | SWIFT_COMPILATION_MODE = wholemodule; 364 | TARGETED_DEVICE_FAMILY = "1,2"; 365 | VALIDATE_PRODUCT = YES; 366 | }; 367 | name = Release; 368 | }; 369 | BA6E6D5A1A529CB20005985D /* Debug */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 373 | CODE_SIGN_IDENTITY = "iPhone Developer"; 374 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 375 | INFOPLIST_FILE = DragDrop/Info.plist; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 377 | PRODUCT_BUNDLE_IDENTIFIER = "LiorN.$(PRODUCT_NAME:rfc1034identifier)"; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | PROVISIONING_PROFILE = ""; 380 | SWIFT_VERSION = 5.0; 381 | }; 382 | name = Debug; 383 | }; 384 | BA6E6D5B1A529CB20005985D /* Release */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 388 | CODE_SIGN_IDENTITY = "iPhone Developer"; 389 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 390 | INFOPLIST_FILE = DragDrop/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 392 | PRODUCT_BUNDLE_IDENTIFIER = "LiorN.$(PRODUCT_NAME:rfc1034identifier)"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | PROVISIONING_PROFILE = ""; 395 | SWIFT_VERSION = 5.0; 396 | }; 397 | name = Release; 398 | }; 399 | BA6E6D5D1A529CB20005985D /* Debug */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | BUNDLE_LOADER = "$(TEST_HOST)"; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(SDKROOT)/Developer/Library/Frameworks", 405 | "$(inherited)", 406 | ); 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | INFOPLIST_FILE = DragDropTests/Info.plist; 412 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 413 | PRODUCT_BUNDLE_IDENTIFIER = "LiorN.$(PRODUCT_NAME:rfc1034identifier)"; 414 | PRODUCT_NAME = "$(TARGET_NAME)"; 415 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DragDrop.app/DragDrop"; 416 | }; 417 | name = Debug; 418 | }; 419 | BA6E6D5E1A529CB20005985D /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | BUNDLE_LOADER = "$(TEST_HOST)"; 423 | FRAMEWORK_SEARCH_PATHS = ( 424 | "$(SDKROOT)/Developer/Library/Frameworks", 425 | "$(inherited)", 426 | ); 427 | INFOPLIST_FILE = DragDropTests/Info.plist; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 429 | PRODUCT_BUNDLE_IDENTIFIER = "LiorN.$(PRODUCT_NAME:rfc1034identifier)"; 430 | PRODUCT_NAME = "$(TARGET_NAME)"; 431 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DragDrop.app/DragDrop"; 432 | }; 433 | name = Release; 434 | }; 435 | /* End XCBuildConfiguration section */ 436 | 437 | /* Begin XCConfigurationList section */ 438 | BA6E6D351A529CAC0005985D /* Build configuration list for PBXProject "DragDrop" */ = { 439 | isa = XCConfigurationList; 440 | buildConfigurations = ( 441 | BA6E6D571A529CB20005985D /* Debug */, 442 | BA6E6D581A529CB20005985D /* Release */, 443 | ); 444 | defaultConfigurationIsVisible = 0; 445 | defaultConfigurationName = Release; 446 | }; 447 | BA6E6D591A529CB20005985D /* Build configuration list for PBXNativeTarget "DragDrop" */ = { 448 | isa = XCConfigurationList; 449 | buildConfigurations = ( 450 | BA6E6D5A1A529CB20005985D /* Debug */, 451 | BA6E6D5B1A529CB20005985D /* Release */, 452 | ); 453 | defaultConfigurationIsVisible = 0; 454 | defaultConfigurationName = Release; 455 | }; 456 | BA6E6D5C1A529CB20005985D /* Build configuration list for PBXNativeTarget "DragDropTests" */ = { 457 | isa = XCConfigurationList; 458 | buildConfigurations = ( 459 | BA6E6D5D1A529CB20005985D /* Debug */, 460 | BA6E6D5E1A529CB20005985D /* Release */, 461 | ); 462 | defaultConfigurationIsVisible = 0; 463 | defaultConfigurationName = Release; 464 | }; 465 | /* End XCConfigurationList section */ 466 | }; 467 | rootObject = BA6E6D321A529CAC0005985D /* Project object */; 468 | } 469 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/project.xcworkspace/xcuserdata/Lior.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lior539/DragDropCollectionView/5d1d3ef8d82f18b61c023025a1411ecbe84a8bd1/Sample Project/DragDrop.xcodeproj/project.xcworkspace/xcuserdata/Lior.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/project.xcworkspace/xcuserdata/prog.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lior539/DragDropCollectionView/5d1d3ef8d82f18b61c023025a1411ecbe84a8bd1/Sample Project/DragDrop.xcodeproj/project.xcworkspace/xcuserdata/prog.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/xcuserdata/Lior.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/xcuserdata/Lior.xcuserdatad/xcschemes/DragDrop.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/xcuserdata/Lior.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DragDrop.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | BA6E6D391A529CAD0005985D 16 | 17 | primary 18 | 19 | 20 | BA6E6D4E1A529CB10005985D 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/xcuserdata/prog.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 88 | 100 | 101 | 102 | 104 | 116 | 117 | 118 | 120 | 132 | 133 | 134 | 136 | 148 | 149 | 150 | 152 | 164 | 165 | 166 | 168 | 180 | 181 | 182 | 184 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /Sample Project/DragDrop.xcodeproj/xcuserdata/prog.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DragDrop.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sample Project/DragDrop/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lior539/DragDropCollectionView/5d1d3ef8d82f18b61c023025a1411ecbe84a8bd1/Sample Project/DragDrop/.DS_Store -------------------------------------------------------------------------------- /Sample Project/DragDrop/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DragDrop 4 | // 5 | // Created by Lior Neu-ner on 2014/12/30. 6 | // Copyright (c) 2014 LiorN. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Sample Project/DragDrop/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Sample Project/DragDrop/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | 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 | -------------------------------------------------------------------------------- /Sample Project/DragDrop/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Sample Project/DragDrop/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Sample Project/DragDrop/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DragDrop 4 | // 5 | // Created by Lior Neu-ner on 2014/12/30. 6 | // Copyright (c) 2014 LiorN. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, UICollectionViewDataSource, DrapDropCollectionViewDelegate { 12 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 13 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath as IndexPath) as UICollectionViewCell 14 | cell.backgroundColor = colors[indexPath.row] 15 | return cell 16 | } 17 | 18 | func dragDropCollectionViewDidMoveCellFromInitialIndexPath(_ initialIndexPath: IndexPath, toNewIndexPath newIndexPath: IndexPath) { 19 | let colorToMove = colors[initialIndexPath.row] 20 | colors.remove(at: initialIndexPath.row) 21 | colors.insert(colorToMove, at: newIndexPath.row) 22 | } 23 | 24 | @IBOutlet var dragDropCollectionView: DragDropCollectionView! 25 | var colors: [UIColor] = { 26 | var randomColors = [UIColor]() 27 | for i in 1...500 { 28 | let randomRed = CGFloat(arc4random() % 255) / 255.0 29 | let randomGreen = CGFloat(arc4random() % 255) / 255.0 30 | let randomBlue = CGFloat(arc4random() % 255) / 255.0 31 | randomColors.append(UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0)) 32 | } 33 | return randomColors 34 | }() 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | dragDropCollectionView.draggingDelegate = self 39 | dragDropCollectionView.enableDragging(true) 40 | } 41 | 42 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 43 | return colors.count 44 | } 45 | 46 | 47 | 48 | @IBAction func toggleWiggle(sender: UISwitch) { 49 | if sender.isOn { 50 | 51 | dragDropCollectionView.startWiggle() 52 | 53 | } else { 54 | dragDropCollectionView.stopWiggle() 55 | } 56 | } 57 | } 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Sample Project/DragDropTests/DragDropTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DragDropTests.swift 3 | // DragDropTests 4 | // 5 | // Created by Lior Neu-ner on 2014/12/30. 6 | // Copyright (c) 2014 LiorN. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class DragDropTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sample Project/DragDropTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lior539/DragDropCollectionView/5d1d3ef8d82f18b61c023025a1411ecbe84a8bd1/demo.gif --------------------------------------------------------------------------------