Git Product home page Git Product logo

imessagestylereveal's Introduction

Purpose

I recently needed to build the iMessage style pull-to-reveal timestamps feature for a personal project and decided to open source the implementation.

Installation

Simply add the following to your Podfile:

Latest release uses Swift 5: pod RevealableCell

If you need Swift 2.2: pod 'RevealableCell', '1.1'

If you need Swift 3.0: pod 'RevealableCell', '2.0'


Then add the following import at the top of your source file(s):

Swift import RevealableCell Obj-C @import RevealableCell

Usage

In order to use RevealableCell in your application, follow the steps below:

  1. Your cell must be a subclass of RevealableTableViewCell

  2. You must register a nib or a RevealableView subclass using:

    tableView.registerNib(nib, forRevealableViewReuseIdentifier: "identifier") or tableView.registerClass(revealableViewClass, forRevealableViewReuseIdentifier: "identifier")

  3. In cellForRowAtIndexPath you can dequeue and configure an instance using:

    if let view = tableView.dequeueReusableRevealableViewWithIdentifier("identifier") as? MyRevealableView {
      view.titleLabel.text = "" // configure
      cell.setRevealableView(view, style: .Slide, direction: .Left)
    }

This new implementation, provides reusable views of the same type as well as allowing you to have different styles or directions for individual cells.

Run this project, to see a demo similar to the iMessage app on your iOS device.

Additional Info

RevealableViews also support AutoLayout now, so if you've setup your constraints correctly, the views will auto-size their widths (per cell) for you. However, you can also specify a fixed width for each cell using

cell.revealableView.width = 100

Note: The height will always be the same as the cell and the position is based on the .style of the RevealableView

Feel free to use in any way you see fit. Please try and reference me somewhere in your app if you use this in a production app and maybe even tell me about it via Twitter @shaps ;)

Screenshot

Supported OS & SDK Versions

  • Supported build target - iOS 8.0
  • Earliest supported deployment target - iOS 8.0

imessagestylereveal's People

Contributors

grzegorzkrukowski avatar kevingogii avatar salehaldhobaie avatar shaps-test avatar shaps80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.