Git Product home page Git Product logo

jtsactionsheet's Introduction

JTSActionSheet

Replacement for UIActionSheet on iOS 7, with customizable fonts and colors, and block-based actions.

Screenshots

Both of these screenshots were made with JTSActionSheet. I've taken great pains to mimic the native look of UIActionSheet on iOS 7 where possible.

Why Use This?

JTSActionSheet will help you if your project has any of these requirements:

  • You need to specify custom fonts for buttons and titles.
  • You would like to choose custom colors for everything: button titles, background colors, etc.
  • You want to use a simple block-based API for button actions.
  • You need to easily drop back to a native appearance for some edge cases.

Surprisingly, there aren't any other ready-made solutions available in the wild. So I made one.

When Not To Use This

Don't use this if you need:

  • iOS 8 features like those provided by UIAlertController.
  • iPad support. It might work on the iPad, but I highly doubt it will look good.
  • Scrollable action sheets (you know, how the native UIActionSheet becomes a scrollable table view when there are too many items to fit in a given area).
  • Landscape support (unless you don't mind a wide horizontal stretch).

How to Use This

It's pretty easy. The steps are:

  1. Create a JTSActionSheetTheme, either from scratch or with defaultTheme.
  2. Setup JTSActionSheetItems representing your buttons and cancel button.
  3. Create and show a new JTSActionSheet.

Here is some sample code showing it all together:

// Import this

#import "JTSActionSheet.h"

[...]

// Create a theme

JTSActionSheetTheme *theme = [JTSActionSheetTheme defaultTheme];


// Setup your buttons

JTSActionSheetItem *buyAll = [JTSActionSheetItem itemWithTitle:@"Buy All" action:^{
    // do stuff
} isDestructive:NO];

JTSActionSheetItem *deleteAll = [JTSActionSheetItem itemWithTitle:@"Delete All" action:^{
    // do stuff
} isDestructive:YES];

JTSActionSheetItem *cancel = [JTSActionSheetItem itemWithTitle:@"Cancel" action:^{
    // respond to cancellation
    // Action blocks can be nil if you want.
} isDestructive:NO];


// Create & Show an Action Sheet

JTSActionSheet *sheet = [[JTSActionSheet alloc] initWithTheme:theme
                                                        title:@"Your Options"
                                                  actionItems:@[buyAll, deleteAll]
                                                   cancelItem:cancel];
[sheet showInView:self.view];

jtsactionsheet's People

Contributors

jaredsinclair avatar

Watchers

James Cloos avatar Can Chen 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.