Giter Club home page Giter Club logo

ohcubeview's Introduction

OHCubeView

Scroll view subclass inspired by the Instagram Stories cube.

demonstration

Requirements

  • iOS >= 9.0
  • Autolayout

N.B.

Only supports portrait mode.

Installation

CocoaPods

In your podfile, add pod 'OHCubeView' and run pod install. Done!

Usage

  • Using interface builder, add a UIScrollView instance to the storyboard and make it a subclass of OHCubeView. Hook the instance up to an IBOutlet in the view controller.

Usage 1

  • In your view controller, programmatically add subviews to the cube view (note that this can be any kind of UIView subclass). Layout constraints are automatically added to the subviews.
import UIKit
import OHCubeView

class ViewController: UIViewController {

    @IBOutlet weak var cubeView: OHCubeView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 1. Create subviews for our cube view (in this case, five image views)
        
        let iv1 = UIImageView(image: UIImage(named: "img1"))
        let iv2 = UIImageView(image: UIImage(named: "img2"))
        let iv3 = UIImageView(image: UIImage(named: "img3"))
        let iv4 = UIImageView(image: UIImage(named: "img4"))
        let iv5 = UIImageView(image: UIImage(named: "img5"))
        
        // 2. Add all subviews to the cube view
        
        cubeView.addChildViews([iv1, iv2, iv3, iv4, iv5])
    }
}

TODOs

  • Support for infinite paging
  • Add custom delegate methods

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.