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

Overview

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.

Comments
  • StatusBar shown only device

    StatusBar shown only device

    Statusbar is hidden with simulator, but statusbar is shown with device.

    And in 4 inch(ex iPhone 5) device, close button not touched well(this issue also with device, not simulator)

    opened by seapy 6
  • Autorotation problem

    Autorotation problem

    Hi, I'm implementing your work into my project (thank you for sharing) and it seams I was able to do it correctly.

    Unfortunately I've got problems during rotation while I'm inside the PhotoSlider.ViewController: moving the orientation from there produces a weird disposition of the view. It seams like it misses the new framework size. Because I'm a beginner I wasn't able to solve it alone. Could you give an hint about it? Thank you Alessandro

    opened by famAlex 5
  • Feature/caption customization options

    Feature/caption customization options

    Changes

    I added the three settings below:

    1. hasCaptionShadow = true
      • Turned on by default
    2. public var captionFont: UIFont?
      • Turned off if not set
    3. public var captionLineHeight: CGFloat?
      • Turned off if not set
    opened by yhkaplan 4
  • slider.index = indexPath.row error after pod update

    slider.index = indexPath.row error after pod update

    Hi, as I wrote in the title, after upgrading from version 0.4.0 to 0.6.0, the line "slider.index = indexPath.row" gives me an error but deleting it my app seams to work correctly. I just wanted to report for let the instructions up to date.

    PS: any plan to fix the rotation behavior on iPad?
    Many thanks

    opened by famAlex 4
  • Fixed swift-version for Cocoapods deployment

    Fixed swift-version for Cocoapods deployment

    $ pod lib lint etc wasn't working, but fixing the .swift-version file got it working!

    The lint/build worked with pod lib lint PhotoSlider.podspec --swift-version=4.0, so I suspected it was a Swift version issue somewhere... After grepping around, I found the .swift-version file. This thread really helped: https://github.com/CocoaPods/CocoaPods/issues/6217

    opened by yhkaplan 3
  • Adding captionBackgroundView

    Adding captionBackgroundView

    目的 Purpose

    キャプションを表示する機能はあるのですが、画面によっては見えにくくなったりしますので、 半透明なバックラウンドビューを見せたいです。 There's a feature for showing captions, but it's difficult to see depending on the screen, so I would like to show a translucent background view.

    実装内容

    1. キャプション背景の色選択
    2. キャプション背景の固定の高さオプション
    3. キャプション背景のAutoLayoutを使った、キャプションテキストに合わせるオプション

    今後PRを考えている要素 Areas of consideration for future PRs

    1. キャプションテキストのカストマイズオプション(shadowなど) More customization options for caption text (shadow, etc)
    2. アニメーションの一部のリファクタ Some refactoring with the animations
    3. ドキュメンテーションの追加 Some additional documentation
    opened by yhkaplan 3
  • crash in iOs 11

    crash in iOs 11

    In iOs 11 PhotoSlider crach on "effectView.addSubview(backgroundView)" in ViewController.swift. Works with "effectView.contentView.addSubview(backgroundView)"

    opened by marten83 3
  • Zoom problem

    Zoom problem

    In previous versions of PhotoSlider was possible zooming images once open. With 0.14.1 is not possible anymore.

    The init code

    var photos: [PhotoSlider.Photo] = [] for image in images { photos += [PhotoSlider.Photo(imageURL:image, caption: "")] } let slider = PhotoSlider.ViewController(photos: photos ) slider.currentPage = index slider.visiblePageControl = false viewController.present(slider, animated: true, completion: nil)

    opened by dariopellegrini 3
  • Fix orientation bug when device is laying on surface

    Fix orientation bug when device is laying on surface

    UIDeviceOrientation can be not only .Portrait and .Landscape, but also .Flat. So I'm using the interface orientation of the view controller itself to determine the right rect. (tested only for portrait because my project is portrait only)

    opened by zubko 3
  • update podspec, point to specific version of kingfisher

    update podspec, point to specific version of kingfisher

    @nakajijapan

    Problem

    I was getting errors with the tagged version not specifying a dependancy version for kingfisher, but also not having this commit https://github.com/nakajijapan/PhotoSlider/commit/779d9d4b908ca87b5534b59f59e653c417d36fdd.

    Solution

    Use the updated version of kingfisher explicitly, and update the pod spec

    opened by karlhungus 3
  • application crash while close fullscreen when image is loading

    application crash while close fullscreen when image is loading

    Application crash with: fatal error: unexpectedly found nil while unwrapping an Optional value when click close while image is loading in full screen page control view

    Check on Swift 2, iOS 9

    opened by Pyrolr 3
  • Swift Package Manager correct adaptation

    Swift Package Manager correct adaptation

    Issues resolved for Xcode 13:

    1. Resolved warning related to missing resource according to the path Source/PhotoSlider.xcassets, but it was located at Source/PhotoSlider/PhotoSlider.xcassets
    2. Changed the way of fetching Kingsfisher dependency from SSH to HTTPS. As not every dev has set up ssh configuration to GitHub therefor it's good practice to use HTTPS that ain't constrained developers
    opened by TomchyshenDenys 3
  • Swift Package Fail

    Swift Package Fail

    Xcode 11 "PhotoSlider >=0.14.2 contains incompatible tools version and root depends on PhotoSlider 1.0.0, version solving failed."

    Thanks for your help ;-)

    opened by jerometonnelier 0
  • change background color

    change background color

    Hello, I am trying to change the background color of the PhotoSlider view controller. So far the PhotoSliderViewcontroller itself changes fine, but the transition doesn't look really nice now, since the origin and destination viewcontroller have white background and the transition has a black background color. Is there a way to make this change smoother?

    opened by luicm 0
Releases(1.5.0)
Owner
Daichi Nakajima
Software Engineer. I like Swift.
Daichi Nakajima
Simple and light weight slider with chapter management

Simple and light weight slider with chapter management Demo Installation CocoaPods WESlider is available through CocoaPods. To install it, simply add

Lucas Ortis 89 Nov 29, 2022
TriggerSlider is a simple SwiftUI trigger slider

TriggerSlider is a simple SwiftUI trigger slider which can be used instead of a button, e.g. in a situation where the

Dominik Butz 4 Dec 16, 2022
A simple range slider made in Swift

RangeSlider Summary A simple range slider made in Swift. Screenshot Use This control is IBDesignable and uses the target-action pattern for change not

William Archimede 305 Nov 29, 2022
Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle!

iLabeledSeekSlider Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle! Minimum iOS v

Edgar Žigis 9 Aug 16, 2022
A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range.

TTRangeSlider A slider, similar in style to UISlider, but which allows you to pick a minimum and maximum range. Installation TTRangeSlider is availabl

Tom Thorpe 952 Dec 2, 2022
A powerful Circular Slider. It's written in Swift, it's 100% IBDesignable and all parameters are IBInspectable.

CircularSlider A powerful Circular Slider. It's written in Swift, it's 100% IBDesignable and all parameters are IBInspectable. Demo Installation Circu

Matteo Tagliafico 253 Sep 19, 2022
VerticalSlider - An animatable and customizable vertical slider written in Swift 4

VerticalSlider An animatable and customizable vertical slider written in Swift 4. Quick Start VerticalSliderPlayground Clone Repo Open VSVerticalSlide

Vincent Smithers 13 Apr 26, 2022
🎚️ STDiscreteSlider – slider which allows user to choose value only from predefined set of data.

STDiscreteSlider – slider which allows user to choose value only from predefined set of data. Slider may receive any types of options, you may pass set of integers or strings, or any other type. Written using SwiftUI.

Tamerlan Satualdypov 15 Apr 3, 2022
A reusable Slider View made with SwiftUI

ZSlider A reusable Slider View made with SwiftUI. Installation: Minimum version iOS 13 In Xcode go to File -> Swift Packages -> Add Package Dependency

null 7 Dec 15, 2022
This is an iOS Tweak that modifies the brightness slider in the Control Center.

AdvancedBrightnessSlider Tweak This is an iOS Tweak that modifies the brightness slider in the Control Center. Even with dark mode toggled on, I found

Jonas Schiefner 18 Jan 5, 2023
Use UIResponder to imitate an iOS slider.

WWSlider Use UIResponder to imitate an iOS slider. 使用UIResponder仿造一個iOS的滑桿. Installation with Swift Package Manager dependencies: [ .package(url:

William-Weng 2 May 5, 2022
VolumeControl is a custom volume control for iPhone featuring a well-designed round slider.

#VolumeControl VolumeControl is a custom volume control for iPhone featuring a well-designed round slider. Preview Usage // Include VolumeControl.h in

12Rockets 81 Oct 11, 2022
IntervalSlider is a slider library like ReutersTV app. written in pure swift.

IntervalSlider Description and appetize.io`s DEMO To run the example project, clone the repo, and run pod install from the Example directory first. Re

Nobuyasu 65 May 23, 2021
CircleSlider is a Circular slider library. written in pure Swift.

CircleSlider Description and appetize.io`s DEMO Usage To run the example project, clone the repo, and run pod install from the Example directory first

Nobuyasu 142 May 9, 2022
A UISlider subclass that displays the slider value in a popup view

ASValueTrackingSlider ###What is it? A UISlider subclass that displays live values in an easy to customize popup view. ![screenshot] (http://alskipp.g

Al Skipp 1.8k Dec 16, 2022
Customizable animated slider for iOS

MMSegmentSlider MMSegmentSlider is an easy-to-use IBDesignable animated slider for iOS 7+ written in Objective-C. Installation From CocoaPods CocoaPod

Max Medvedev 48 Jul 26, 2022
StepSlider its custom implementation of slider such as UISlider for preset integer values.

StepSlider StepSlider its custom implementation of slider such as UISlider for preset values. Behind the scenes StepSlider manipulate integer indexes.

spromicky 520 Dec 20, 2022
An iOS Slider written in Swift.

JDSlider Beetripper App's screenshots Example Project To run the example project, clone the repo, and run pod install from the Example directory first

Jelly Development 84 Jul 26, 2022
A beautiful slider control for iOS built purely upon Swift

SnappingSlider A beautiful slider control for iOS. Installation There are two ways to add the control to your project; you can add it as a submodule i

Rehat Kathuria 577 Dec 15, 2022