All Projects → c2mInc → Snap2me

c2mInc / Snap2me

Licence: MIT license
Snap2me helps you add the snap guides into your views.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Snap2me

Version License Platform

Snap2me helps you add the snap feature to your views. Your views need some guidance when users drag and drop things in it. Snap2me helps you implement these line guides into any view and its subviews are snapped once they are captured in a threshold.

Example project

To run the example project, open up a terminal screen and copy paste the code below:

pod try 'Snap2me'

Storyboard support

Put two views in a view controller, then you can bind viewToSnapInStoryBoard by dragging property, right in the Xcode.

Storyboard

Programmatic support

You can set snapping lines just like the following.

draggingView.axisPercentages = [
    GuideLine.AxisPercentage(axis: .vertical, percentage: 0.5),
    GuideLine.AxisPercentage(axis: .horizontal, percentage: 0.5),
    GuideLine.AxisPercentage(axis: .horizontal, percentage: 0.1),
    GuideLine.AxisPercentage(axis: .vertical, percentage: 0.1),
    GuideLine.AxisPercentage(axis: .horizontal, percentage: 0.9),
    GuideLine.AxisPercentage(axis: .vertical, percentage: 0.9)
]

Programmatic

Customization

draggableView.settings = GuideLine.Settings(
    lineColor: UIColor.red,
    lineWidth: 4,
    shadowColor: UIColor.brown,
    flushesInitially: true,
    threshold: 15
)

Installation

Snap2me is available through CocoaPods. To install it, add the following line to your Podfile:

pod 'Snap2me'

Features

  • Clean, easy to comprehend swift implementation, subclass the Snap2meView and enjoy dragging
  • Storyboard implementation
  • Programmatic implementation
  • Percent driven guide line distances
  • Constant guide line distances
  • Orientation handling
  • Top, bottom, left, right snaps
  • IBDesignables and IBInspectibles for Snap2meView
  • Wider test coverage

Tests

To run the tests simply select test target and select Snap2me_Example as the host application. This is caused by an issue between Cocoapods and modern Xcode versions.

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 4.0+

Author

Connected2.me / Erk Ekin @erkekin

Contribution

IBDesignable and IBInspectible for guide lines, constant line distance accompanying to percentage, top, bottom, left and right snaps, support for rotaion change are considered to be improved, please contribute!

License

Snap2me is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].