All Projects → nakajijapan → Photoslider

nakajijapan / Photoslider

Licence: mit
PhotoSlider is a simple photo slider and can delete slider with swiping.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Photoslider

Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (-53.16%)
Mutual labels:  xcode, carthage, viewcontroller
Device
Light weight tool for detecting the current device and screen size written in swift.
Stars: ✭ 1,503 (+534.18%)
Mutual labels:  xcode, carthage
Loolocator
A simple iOS app that fetches the crowd-sourced data from OpenStreetMaps, and shows toilets within walking distance.
Stars: ✭ 234 (-1.27%)
Mutual labels:  xcode, carthage
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-49.79%)
Mutual labels:  xcode, carthage
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+549.79%)
Mutual labels:  xcode, carthage
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+4417.3%)
Mutual labels:  xcode, carthage
Microfeatures Example
📦📱 Example of iOS app built using the uFeatures architecture
Stars: ✭ 112 (-52.74%)
Mutual labels:  xcode, carthage
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-62.03%)
Mutual labels:  xcode, carthage
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-44.73%)
Mutual labels:  xcode, carthage
Donut
Donut is a library for arranging views circularly like a donut.
Stars: ✭ 141 (-40.51%)
Mutual labels:  xcode, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-33.33%)
Mutual labels:  xcode, carthage
Rdgliderviewcontroller Swift
Control for a floating view gliding over a ViewController Edit
Stars: ✭ 102 (-56.96%)
Mutual labels:  carthage, viewcontroller
Collectionnode
a collectionView made for Sprite Kit
Stars: ✭ 96 (-59.49%)
Mutual labels:  xcode, carthage
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+15467.93%)
Mutual labels:  xcode, carthage
Pluggableappdelegate
!! No longer supported !! A lightweight service-oriented AppDelegate for iOS, made in Swift.
Stars: ✭ 96 (-59.49%)
Mutual labels:  xcode, carthage
Carting
🚘 A simple tool for updating Carthage script phase
Stars: ✭ 182 (-23.21%)
Mutual labels:  xcode, carthage
Corenavigation
📱📲 Navigate between view controllers with ease. 💫 🔜 More stable version (written in Swift 5) coming soon.
Stars: ✭ 69 (-70.89%)
Mutual labels:  xcode, carthage
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+397.89%)
Mutual labels:  xcode, carthage
Croc
Swift emoji string parsing library
Stars: ✭ 124 (-47.68%)
Mutual labels:  xcode, carthage
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: ✭ 172 (-27.43%)
Mutual labels:  xcode, carthage

PhotoSlider for Swift

Carthage Version License Platform Language Backers on Open Collective Sponsors on Open Collective

PhotoSlider is a simple photo slider and can delete slider with swiping.

Requirements

  • Xcode 9+
  • Swift 4.0+
  • iOS 10+

Installation

CocoaPods

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

pod "PhotoSlider"

Carthage

Carthage is a decentralized dependency manager for Cocoa application.

$ brew update
$ brew install carthage

To integrate PhotoSlider into your Xcode project using Carthage, specify it in your Cartfile:

github "nakajijapan/PhotoSlider"

Then, run the following command to build the PhotoSlider framework:

$ carthage update

Usage

Using ZoomingAnimationControllerTransitioning

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {

    var slider = PhotoSlider.ViewController(imageURLs: self.images)
    slider.currentPage = indexPath.row
    photoSlider.transitioningDelegate = self
    present(photoSlider, animated: true, completion: nil)

}

ZoomingAnimationControllerTransitioning

return imageView for starting position

// MARK: ZoomingAnimationControllerTransitioning

func transitionSourceImageView() -> UIImageView {

    let indexPath = collectionView.indexPathsForSelectedItems?.first
    let cell = collectionView.cellForItem(at: indexPath!) as! ImageCollectionViewCell
    let imageView = UIImageView(image: cell.imageView.image)

    var frame = cell.imageView.frame
    frame.origin.y += UIApplication.shared.statusBarFrame.height

    imageView.frame = frame
    imageView.clipsToBounds = true
    imageView.contentMode = .scaleAspectFill

    return imageView

}

return sourceImageView for finished position

func transitionDestinationImageView(sourceImageView: UIImageView) {

    guard let image = sourceImageView.image else {
        return
    }

    let indexPath = collectionView.indexPathsForSelectedItems?.first
    let cell = collectionView.cellForItem(at: indexPath!) as! ImageCollectionViewCell
    let statusBarHeight = UIApplication.shared.statusBarFrame.height

    // snip..

    sourceImageView.frame = frame

}

UIViewControllerTransitioningDelegate

// MARK: UIViewControllerTransitioningDelegate

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    let animationController = PhotoSlider.ZoomingAnimationController(present: false)
    animationController.sourceTransition = dismissed as? ZoomingAnimationControllerTransitioning
    animationController.destinationTransition = self
    return animationController
}

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    let animationController = PhotoSlider.ZoomingAnimationController(present: true)
    animationController.sourceTransition = source as? ZoomingAnimationControllerTransitioning
    animationController.destinationTransition = presented as? ZoomingAnimationControllerTransitioning
    return animationController
}

Using UIModalTransitionStyle

select ZoomingAnimationController

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {

    var slider = PhotoSlider.ViewController(imageURLs: self.images)
    slider.modalPresentationStyle = .OverCurrentContext
    slider.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
    slider.index = indexPath.row
    self.presentViewController(slider, animated: true, completion: nil)

}

Delegation

You can handle the following event:

  • optional func photoSliderControllerWillDismiss(viewController: PhotoSlider.ViewController)
  • optional func photoSliderControllerDidDismiss(viewController: PhotoSlider.ViewController)

Multiple Image Loader

PhotoSlider use Kingfisher for remote image. If use SDWebImage in your project, image cache is not shared between Kingfisher and SDWebImage. In this case you can make custom ImageLoader. default ImageLoader is Kingfisher.

Here is how to change SDWebImage.

First, create custom ImageLoader.

import PhotoSlider

class PhotoSliderSDImageLoader: PhotoSlider.ImageLoader {
    public func load(
        imageView: UIImageView?,
        fromURL url: URL?,
        progress: @escaping PhotoSlider.ImageLoader.ProgressBlock,
        completion: @escaping PhotoSlider.ImageLoader.CompletionBlock)
    {
        // Webp compatibility (optional)
        let WebPCoder = SDImageWebPCoder.shared
        SDImageCodersManager.shared.addCoder(WebPCoder)
        
        imageView?.sd_setImage(
            withURL: url,
            placeholderImage: nil,
            options: SDWebImageOptions.retryFailed,
            progress: { (receivedSize, totalSize) in
                progress(receivedSize, totalSize)
            },
            completed: { (image, _, _, _) in
                completion(image)
            }
        )
    }
}

and set ImageLoader.

let slider = PhotoSlider.ViewController(imageURLs: images)
slider.modalPresentationStyle = .OverCurrentContext
slider.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
slider.index = indexPath.row
slider.imageLoader = PhotoSliderSDImageLoader()
present(slider, animated: true, completion: nil)

Author

nakajijapan

Special Thanks

  • hikarock
  • yhkaplan
  • seapy
  • antrix1989

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

PhotoSlider 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].