MTDActionSheet 1.1

MTDActionSheet 1.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年9月

Matthias Tretter维护。



  • 作者
  • Matthias Tretter

使用块作为回调的可定制UIActionSheet替代品,用于iPad。

除了标准UIActionSheet功能,MTDActionSheet实例的字体和颜色也可以轻松自定义,并且单元格可以显示额外的辅助标题。此外,还可能禁用某些按钮,这在您使用actionSheet让用户从一组值中选择时很有用,您希望显示但禁用当前选定的值。

截图

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

示例用法

// 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];
}

致谢

MTDActionSheet是由Matthias Tretter (@myell0w)创建,并从漂亮的reddit客户端Biscuit for reddit中提取。

Biscuit for reddit

许可证

MTDActionSheet可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。