Coder Social home page Coder Social logo

mtdactionsheet's Introduction

MTDActionSheet

A customizable UIActionSheet replacement for the iPad using blocks as callbacks.

In addition to the standard UIActionSheet functionality, fonts and colors of instances of MTDActionSheet can be easily customized and cells can show an additional accessory title. Moreover it is possible to disable certain buttons which can be useful if you use the actionSheet to let the user choose from a list of values and you want to show but disable the current selected value.

Screenshots

Screenshot with destructive tint color and accessory Screenshot with left-aligned buttons

Sample Usage

// customize the default appearance of action sheets
+ (void)customizeActionSheets {
    [MTDActionSheet setTitleFont:[UIFont systemFontOfSize:13.f]];
    [MTDActionSheet setButtonTitleFont:[UIFont lightRedditFontOfSize:21.f]];
    [MTDActionSheet setButtonAccessoryFont:[UIFont systemFontOfSize:19.f]];
    [MTDActionSheet setBackgroundColor:[UIColor MTDNavigationBarInPopoverBarTintColor]];
    [MTDActionSheet setSeparatorColor:[UIColor MTDLineColor]];
    [MTDActionSheet setTitleColor:[UIColor MTDActionSheetTitleColor]];
    [MTDActionSheet setTintColor:[UIColor MTDTintColor]];
    [MTDActionSheet setDestructiveTintColor:[UIColor MTDDestructiveTintColor]];
    [MTDActionSheet setDisabledTintColor:[UIColor MTDActionSheetTitleColor]];
    [MTDActionSheet setAccessoryTintColor:[UIColor MTDActionSheetAccessoryColor]];
    [MTDActionSheet setSelectionColor:[UIColor MTDMenuItemCellSelectionColor]];
}

- (void)showActionSheetAtRect:(CGRect)rect {
    MTDActionSheet *actionSheet = [[MTDActionSheet alloc] initWithTitle:@"Submissions from"];

    for (RDTListingSubtype subtype = RDTFirstListingSubtype; subtype <= RDTLastListingSubtype; subtype++) {
        NSString *title = NSStringFromRDTListingSubtype(subtype);
        NSString *accessoryTitle = (subtype == self.listingSubtype) ? @"โœ“" : nil;

        [actionSheet addButtonWithTitle:title accessoryTitle:accessoryTitle block:^(MTDActionSheet *sheet, NSInteger buttonIndex) {
            self.listingSubtype = subtype;
            self.subreddit.preferredListingSubtypeValue = subtype;
            [self reloadVisibleItemsShowingHUD:YES];
        }];

        if (subtype == self.listingSubtype) {
            [actionSheet disableButtonWithTitle:title];
        }
    }

    // customize the title color of only this instance
    actionSheet.titleColor = [UIColor blueColor];
    [actionSheet showFromRect:rect inView:self.view animated:YES];
}

Credits

MTDURLPreview was created by Matthias Tretter (@myell0w) and extracted from the beautiful reddit client Biscuit for reddit.

Biscuit for reddit

License

MTDURLPreview is available under the MIT license. See the LICENSE file for more info.

mtdactionsheet's People

Contributors

myell0w avatar

Watchers

James Cloos avatar Andrew Shmig 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.