{"id":18754823,"url":"https://github.com/pauljeannot/snapsliderfilters","last_synced_at":"2025-04-09T17:26:16.596Z","repository":{"id":62455707,"uuid":"58006962","full_name":"pauljeannot/SnapSliderFilters","owner":"pauljeannot","description":"Snapchat like filters, slider, stickers and textfield !","archived":false,"fork":false,"pushed_at":"2019-09-15T01:46:09.000Z","size":1360,"stargazers_count":274,"open_issues_count":8,"forks_count":41,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-02T11:55:17.893Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pauljeannot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-03T23:01:43.000Z","updated_at":"2024-11-21T06:44:09.000Z","dependencies_parsed_at":"2022-11-01T22:46:34.552Z","dependency_job_id":null,"html_url":"https://github.com/pauljeannot/SnapSliderFilters","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauljeannot%2FSnapSliderFilters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauljeannot%2FSnapSliderFilters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauljeannot%2FSnapSliderFilters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauljeannot%2FSnapSliderFilters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pauljeannot","download_url":"https://codeload.github.com/pauljeannot/SnapSliderFilters/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248076203,"owners_count":21043730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T17:30:10.434Z","updated_at":"2025-04-09T17:26:16.582Z","avatar_url":"https://github.com/pauljeannot.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SnapSliderFilters\n\n[![Version](https://img.shields.io/cocoapods/v/SnapSliderFilters.svg?style=flat)](http://cocoapods.org/pods/SnapSliderFilters)\n[![License](https://img.shields.io/cocoapods/l/SnapSliderFilters.svg?style=flat)](http://cocoapods.org/pods/SnapSliderFilters)\n[![Platform](https://img.shields.io/cocoapods/p/SnapSliderFilters.svg?style=flat)](http://cocoapods.org/pods/SnapSliderFilters)\n\nSnapSliderFilters allows you to create easily a SnapChat like navigation between a picture and its filters (that you can automatically generate). You can add stickers above the slides, tap on the screen to add a message and place it wherever you want, exactly as you do every day on SnapChat !\n\n![Gif example 1](https://media.giphy.com/media/l0K4a2gNdOxrMH3Tq/giphy.gif)\n![Gif example 2](https://media.giphy.com/media/26FxxUyEKHtLQHwrK/giphy.gif)\n![Gif example 3](https://media.giphy.com/media/oXPF7y8JHUJsQ/giphy.gif)\n\n## Installation with CocoaPods\n\nSnapSliderFilters is available through [CocoaPods](http://cocoapods.org). To install\nit, add the following line to your Podfile:\n\n```ruby\npod \"SnapSliderFilters\"\n```\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\nThis demo allows you to import your own image from the camera roll and to save the final edited image.\n\n## Requirements\n\n#### Platform\n\n- Swift 3\n- Xcode 8\n- iOS 9\n\n#### Supported Device\n\niPhone 4s, 5, 5s, 5c, 6, 6 Plus, 6s, 6s Plus, all iPad having iOS 9.\n\n## How to use\n\n### Slider\n\nTo insert a slider in your ViewController, all you need is to create the slider, load the data and show it.\n\nThe slider **must** be displayed in fullscreen. `SNUtils` allows you to do it easily :\n```swift\nvar slider = SNSlider(frame: CGRect(origin: CGPointZero, size: SNUtils.screenSize))\n```\n\nThen, you can generate filters from your original picture, using the [Core Image Filter](https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/). `SNFilter.filterNameList`is a small selection of filters that you can use for a quick demo :\n```swift \n// Create your original filter\nvar originalPicture = SNFilter(frame: slider.frame, withImage: UIImage(named: \"yourPicture\")!)\n// Generate differents filters by passing in argument the original picture and an array of filter's name\nvar data  = SNFilter.generateFilters(originalPicture, filters: SNFilter.filterNameList)\n```\n\nYou can add some stickers above your filters, by creating a `SNSticker` and adding it to the proper filter :\n```swift\nvar sticker = SNSticker(frame: CGRect(x: 20, y: 0, width: 140, height: 140), image: UIImage(named: \"sticker1\")!)\n// In case of overlapping, you can provide a zPosition (the default one is 0)\nvar sticker2 = SNSticker(frame: CGRect(x: 30, y: 0, width: 140, height: 140), image: UIImage(named: \"sticker2\")!, atZPosition: 2))\n\n// 2 stickers will be added to the filter at index 1\nself.data[1].addSticker(sticker)\nself.data[1].addSticker(sticker2)\n```\n\nYour ViewController must conform to the `SNSliderDataSource` protocol. It allows the slider to be populated with your own data.\n\n```swift\nextension ViewController: SNSliderDataSource {\n  \n  // The number of SNFilters that you want in the slider\n  func numberOfSlides(slider: SNSlider) -\u003e Int {\n    return data.count\n  }\n  \n  // For a given index, you return the corresponding SNFilter\n  func slider(slider: SNSlider, slideAtIndex index: Int) -\u003e SNFilter {\n    return data[index]\n  }\n  \n  // The starting index of the slider\n  func startAtIndex(slider: SNSlider) -\u003e Int {\n    return 0\n  }\n}\n```\n\nFinally, you can show the slider :\n\n```swift \nslider.dataSource = self\nslider.userInteractionEnabled = true\nview.addSubview(slider)\nslider.reloadData()\n```\n\n### TextField\n\nIf you want to add a Snapchat like textfield above your slider, your can do it easily as well. Firstly, create the `SNTextField` : all you need to pass is your `y` starting point for the textfield, the width and the height of your screen (once again, `SNUtils` can help you).\n\n```swift\nvar textfield = SNTextField(y: SNUtils.screenSize.height/2, width: SNUtils.screenSize.width, heightOfScreen: SNUtils.screenSize.height)\n```\n\nMake sure to put it above all your views by adding it to just after the initialization, and then show it :\n```swift \ntextField.layer.zPosition = 100\nself.view.addSubview(textField)\n```\n\nNow a little bit of boilerplate code, to create observers for the keyboard behaviour and to detect the tap gesture :\n```swift \nvar tapGesture:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))\ntapGesture.delegate = self\nslider.addGestureRecognizer(tapGesture)\n\nNSNotificationCenter.defaultCenter().addObserver(self.textField, selector: #selector(SNTextField.keyboardWillShow(_:)), name: UIKeyboardWillShowNotification, object: nil)\nNSNotificationCenter.defaultCenter().addObserver(self.textField, selector: #selector(SNTextField.keyboardWillHide(_:)), name: UIKeyboardWillHideNotification, object: nil)\nNSNotificationCenter.defaultCenter().addObserver(self.textField, selector: #selector(SNTextField.keyboardTypeChanged(_:)), name: UIKeyboardDidShowNotification, object: nil)\n```\n\nYou ViewController must conform to the `UIGestureRecognizerDelegate`. Add this extension at the end of your file :\n\n```swift \nextension ViewController: UIGestureRecognizerDelegate {\n  func handleTap() {\n    self.textField.handleTap()\n  }\n}\n```\n\nFinally, do not forget to remove observers :\n```swift\noverride func viewWillDisappear(animated: Bool) {\n  NSNotificationCenter.defaultCenter().removeObserver(textField)\n}\n```\n\n### Buttons\n\nYou can also add some snap-like buttons with a very simple target-action method :\n\n```swift\nprivate let button = SNButton(frame: CGRect(x: 20, y: SNUtils.screenSize.height - 35, width: 33, height: 30), withImageNamed: \"saveButton\")\n\nbutton.setAction {\n  [weak weakSelf = self] in\n  // To do when the button is pressed\n}\n\nview.addSubview(button)\n```\n\n### Get the final-edited image\n\n```swift\nlet picture = SNUtils.screenShot(self.view)\n```\n\nIf you have things on the screen that you don't want on your final image (buttons, ...), you can create another `UIView`, add everything you want to be on the picture as its subviews and perform the screenshot on this view.\n\nYou will find an example of this method in the example project (see `screenView`).\n\n## Author\n\nPaul Jeannot, Computer Science \u0026 Engineering student at University of Technology of Compiègne.\nContact at paul.jeannot95@gmail.com\n\n## License\n\nFree Icons provided by [Icons8](https://icons8.com)\n\nSnapSliderFilters is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauljeannot%2Fsnapsliderfilters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauljeannot%2Fsnapsliderfilters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauljeannot%2Fsnapsliderfilters/lists"}