All Projects β†’ huang-kun β†’ AFTPhotoScroller

huang-kun / AFTPhotoScroller

Licence: MIT license
A simple photo browser using like iOS photo app.

Programming Languages

objective c
16641 projects - #2 most used programming language
shell
77523 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to AFTPhotoScroller

Photoviewslider
πŸ“· A simple photo browser for Android applications.
Stars: ✭ 78 (+290%)
Mutual labels:  photo-browser
Unsplash Photopicker Ios
πŸ“±An iOS photo picker to search and download photos from Unsplash.
Stars: ✭ 213 (+965%)
Mutual labels:  photo-browser
smooth-parallax
Smooth Parallax makes it a lot easier to move objects when the page scroll with ease.
Stars: ✭ 66 (+230%)
Mutual labels:  parallax-scrolling
Photostructure For Servers
PhotoStructure for Servers
Stars: ✭ 98 (+390%)
Mutual labels:  photo-browser
Skphotobrowser
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift
Stars: ✭ 2,285 (+11325%)
Mutual labels:  photo-browser
Imageglass
🏞 A lightweight, versatile image viewer
Stars: ✭ 3,284 (+16320%)
Mutual labels:  photo-browser
Photobrowser
Elegant photo browser in Swift. ε›Ύη‰‡δΈŽθ§†ι’‘ζ΅θ§ˆε™¨γ€‚
Stars: ✭ 975 (+4775%)
Mutual labels:  photo-browser
URParallaxScrollAnimator
Show an animation as far as moved scroll while scrolling at the scroll view
Stars: ✭ 34 (+70%)
Mutual labels:  parallax-scrolling
Mvpapp
Android MVP Architecture
Stars: ✭ 2,354 (+11670%)
Mutual labels:  photo-browser
hongkong
A parallax scroll effect plugin
Stars: ✭ 46 (+130%)
Mutual labels:  parallax-scrolling
Photato
Photato - The personal Pictures gallery
Stars: ✭ 130 (+550%)
Mutual labels:  photo-browser
Lantern
基于Swiftηš„ι«˜ε―η”¨θ§†ε›Ύζ‘†ζžΆ
Stars: ✭ 181 (+805%)
Mutual labels:  photo-browser
Geeqie
claiming to be the best image viewer / photo collection browser
Stars: ✭ 239 (+1095%)
Mutual labels:  photo-browser
Syphotobrowser
A cute and lightweight photo browser like Tweetbot3.
Stars: ✭ 81 (+305%)
Mutual labels:  photo-browser
PhotoMiner
Photo finder application for macOS
Stars: ✭ 102 (+410%)
Mutual labels:  photo-browser
Imageglass Preview
πŸ” A modern, versatile image viewer (preview)
Stars: ✭ 72 (+260%)
Mutual labels:  photo-browser
Fusuma
Instagram-like photo browser and a camera feature with a few line of code in Swift.
Stars: ✭ 2,434 (+12070%)
Mutual labels:  photo-browser
Odyssey
Next generation gallery. Exceptional images deserve an exceptional presentation.
Stars: ✭ 29 (+45%)
Mutual labels:  photo-browser
Parallaxie
Easiest, Responsive and Customizable Parallax jQuery Plugin
Stars: ✭ 65 (+225%)
Mutual labels:  parallax-scrolling
universal-parallax
Easy parallax plugin using pure javascript. Also works on mobile platforms. Cross browser support.
Stars: ✭ 107 (+435%)
Mutual labels:  parallax-scrolling

AFTPhotoScroller

CI Status Version License Platform

ScreenShots

Paging and zooming            Web image

Parallax Scrolling1     Parallax Scrolling2

Introduction


AFTPhotoScroller is a simple and flexible solution for implementing a photo scroller with the basic functionality in iOS photo app.

The inspiration of this is from WWDC 2010 video Designing Apps with Scroll Views, which explains the essence of nested scroll views technique for photo scrolling. There are some great open source projects wrapping everything to make photo scrolling code simple to implement, but AFTPhotoScroller is different.

Like classic photo scroller, AFTPhotoScroller can do left to right page scrolling and single photo zooming. The features of AFTPhotoScroller are:

Controller-Free Design.

Unlike UIPageViewController, there is no controller class for AFTPhotoScroller. This is a view-based public interface and the only one needed class is called AFTPagingScrollView, which means you can do much customized controller for different situations like using UITableView directly instead of UITableViewController. It handles the page reuse, padding calculation and minimum image cache concept just like UIPageViewController, except the page curl effect and spine location.

Customized

There are a lot of details for you to customize:

  • Padding between pages
  • Enable / disable the double tap gesture to zoom image
  • Set zooming progress to determine how far a double tap can zoom.
  • Vertical paging direction support
  • Parallax Scrolling support (like photo app in iOS 10. Check out wikipedia for the concept of Parallax Scrolling if you like)

There are a lot of control flows for you to customize:

  • You can decide whether should display a single page
  • You can jump to specified page directly
  • You can reload a single page (It works well with image network fetching)
  • You can get callback for beginning states of paging, zooming, tapping.
  • You can get callback after a new page is about to fully displayed on screen (When a new page is taken more than half of the screen)

Demo

Objective-C

First, install AFTPhotoScroller. Then #import <AFTPhotoScroller/AFTPhotoScroller.h> In your UIViewController subclass, you can simply just do this.

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.pagingView = [[AFTPagingScrollView alloc] initWithFrame:self.view.bounds];
    self.pagingView.dataSource = self;
    self.pagingView.paddingBetweenPages = 6;
    [self.view addSubview:self.pagingView];
    
    self.images = ... // load images
    [self.pagingView reloadData]; // build UI and load required data
}

#pragma mark - AFTPagingScrollViewDataSource

- (NSInteger)numberOfPagesInPagingScrollView:(AFTPagingScrollView *)pagingScrollView {
    return self.images.count;
}

- (UIImage *)pagingScrollView:(AFTPagingScrollView *)pagingScrollView imageForPageAtIndex:(NSInteger)pageIndex {
    return self.images[pageIndex];
}

Swift

First, install AFTPhotoScroller (MUST use_frameworks! in Podfile) Then import AFTPhotoScroller In your UIViewController subclass, you can simply just do this.

import UIKit
import AFTPhotoScroller

class ViewController: UIViewController, AFTPagingScrollViewDataSource {
    
    var pagingView: AFTPagingScrollView!
    var images: [UIImage]!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        pagingView = AFTPagingScrollView(frame:view.bounds)
        pagingView.isParallaxScrollingEnabled = true
        pagingView.dataSource = self
        view.addSubview(pagingView)
        
        images = loadAllImages()
        pagingView.reloadData()
    }

    public func numberOfPages(in pagingScrollView: AFTPagingScrollView) -> Int {
        return images.count
    }
    
    public func pagingScrollView(_ pagingScrollView: AFTPagingScrollView, imageForPageAt pageIndex: Int) -> UIImage {
        return images[pageIndex]
    }

    func loadAllImages() -> [UIImage] {
        ....
    }
}

The demo app is available for downloading. It is showing how to build different photo scrollers by AFTPhotoScroller. It works well with other UI component like custom bottom page bar. The demo is using presented navigation bar with push animation instead of real UINavigationController.

Unlike demo app, we do not recommend loading all image resources into memory at once in real project.

Requirements

iOS 6+

Installation

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

pod "AFTPhotoScroller"

Thanks

Author

huangkun, [email protected]

License

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