Code Monkey home page Code Monkey logo

zoomablescrollview's Introduction

DEMO

ZoomableScrollView

A Simple Zoomable ScrollView with a View inherited from UIScrollView.

About

When you make an application, which has a viewer feature(like big photo viewer), the viewer usually needs to have zoomable and scrollable features, to allow the user to view more details.
This control help you display a view, with zoomable and scrollable features easily.

Compatible

  • iOS 7 and later (requires iOS 8 if you want to add it to project using CocoaPod)
  • Swift 4.0(version 1.5), Swift 3.0 (version 1.3), 2.0 (version 1.2 and prior)

Usage

Cocoapod

Add below line to Podfile or Run below command in Terminal to install(not support pod api yet):

pod 'ZoomableScrollView', :git => 'https://github.com/tucan9389/ZoomableScrollView.git'

Manual

In iOS 7, you cannot use Cocoapod to install. In this case, you need add it manually. Simply, add file ZoomableScrollView.swift in folder Sources to your project

Simple to use

Drag an UIScrollView to your storyboard, change Class and Module in Identity Inspector to ZoomableScrollView. Also, create an IBOutlet in your source file.

image

import ZoomableScrollView

class ViewController: UIViewController

    @IBOutlet weak var zoomableScrollView: ZoomableScrollView!
    let myView = MyCustomView()

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        zoomableScrollView.display(view: myView)
        // or
        zoomableScrollView.display(image: UIImage(named: "image"))
    }
}

That's all. Now try zooming and scrolling to see the result.

Note: If your view is aligned left instead of center, try calling below method:

superViewOfZoomableScrollView.layoutIfNeeded()

superViewOfZoomableScrollView is the view that ZoomableScrollView is added to.

Features

  • Simple to create zoomable scroll view
  • Double tap to zoom feature
  • Smoother. Fixed bug when zooming out, the control auto zooms from center, and not from the corner.
  • Various ZoomMode(.defaultFit, aspectFill, aspectFit, widthFill, heightFill)

About this source

This open source is based on PhotoScroller demo avaiable on Apple's site. The original source is written in Objective C. This source rewrite uses Swift, and adds some new features

License

ZoomableScrollView is released under the MIT license. See LICENSE for details. Copyright © tucan9389

zoomablescrollview's People

Contributors

tucan9389 avatar

Stargazers

jprothwell avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

magic-ios

zoomablescrollview's Issues

Need zoom method to point parameter

UIScrollView has zoom(to: animated:) method, but not with just point.
For convenience, need more method like below.

func zoom(to point: Point, animated: Bool)
func zoom(at point: Point, to scale: CGFloat, animated: Bool)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.