Giter Club home page Giter Club logo

tiltingscrollview's Introduction

TiltingScrollView

UIScrollView subclass that scrolls when the user tilts the device.

##Usage##

  • Change the class of your UIScrollView to TiltingScrollView.
  • When your view controller appears on screen (most cases in viewWillAppear or viewDidAppear), call scrollView.setTiltingEnabled(true).
  • If at any point you want to stop the tilt-to-scroll, call scrollView.setTiltingEnabled(false). This will automatically set scrollView.scrollingEnabled = true.
  • You can recalibrate the scroll view at any point by calling scrollView.calibrate(). I recommend adding a button that allows the user to choose to recalibrate in order to redefine the angle at which the scroll view goes up and down.

##Public Variables##

/// Factor by which the accelerometer data is multiplied to scroll the view. Larger values cause faster scrolling.

public var tiltingFactor: CGFloat = 20

##Public Methods##

/// Enables or disables the tilting behavior of the scroll view.
/// - true: Tilting the device causes the scroll view to scroll. `scrollingEnabled = false`
/// - false: Tilting the device does nothing. `scrollEnabled = true`

public func setTiltingEnabled(tiltingEnabled: Bool)
/// Resets the internal calculations to use the current angle of the device as the reference point.
/// At the device's current angle, the scroll view will not scroll.

public func calibrate()

Conclusion

If you have any issues or suggestions, please create an issue or a pull request (preferred :). Revisions and improvements are always welcome.

You can contact me on Twitter at @ERDekhayser.

tiltingscrollview's People

Contributors

edekhayser avatar

Watchers

Carabineiro avatar

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.