WCActionSheet 0.1

WCActionSheet 0.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

Wojtek Czekalski维护。




UIActionSheet 很好...除非你没有在你的应用中使用 Helvetica :).

由于我需要更多的自定义和不同的外观,因此我创建了这个 UIActionSheet 的小型替代品。

WCActionSheet

如何使用

#Cocoapods
pod 'WCActionSheet'

#Of course you can also download the source and copy the WCActionSheet.* and UIImage+ImageEffect.* files.

我将 API 设计得尽可能相似于 UIActionSheet。

为了初始化 WCActionSheet,您可以使用以下方法之一
// With this initializer, you are responsible for adding buttons. Standard cancel button is added for you.

WCActionSheet *actionSheet = [[WCActionSheet alloc] init];

// Equivalent to -init. Frame argument is not taken into consideration

WCActionSheet *actionSheet = [[WCActionSheet alloc] initWithFrame:aframe];

// Designed initializer. Similar to UIActionSheet's one.

WCActionSheet *actionSheet = [[WCActionSheet alloc] initWithFrame:initWithDelegate:delegate cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Button !", @"Button 2", nil];
添加按钮
// Adding buttons with action block. This won't fire delegate call -actionSheet:clickedButtonAtIndex

[actionSheet addButtonWithTitle:@"Hi!" actionBlock:^{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hi!" message:@"My name is Wojtek and I made it" delegate:nil cancelButtonTitle:@"okay" otherButtonTitles: nil];
        [alert show];
    }];

// Adding buttons without action block. (This one, when tapped, will fire delegate call.

[actionSheet addButtonWithTitle:@"Bye"];
显示 WCActionSheet
// Showing WCActionSheet is as simple as:

[actionSheet show];
委托协议
@protocol WCActionSheetDelegate <NSObject>
@optional

// Called when a button is clicked. The view will be automatically dismissed after this call returns
- (void)actionSheet:(WCActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;

// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)actionSheetCancel:(WCActionSheet *)actionSheet;

- (void)willPresentActionSheet:(WCActionSheet *)actionSheet;  // before animation and showing view
- (void)didPresentActionSheet:(WCActionSheet *)actionSheet;  // after animation

- (void)actionSheet:(WCActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view
- (void)actionSheet:(WCActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;  // after animation

@end
自定义外观
// You may use UIAppearance proxy in order to set following properties. (You can also set the properties directly)

@property(nonatomic) CGFloat blurRadius UI_APPEARANCE_SELECTOR;

@property(nonatomic, strong) UIColor *blurTintColor UI_APPEARANCE_SELECTOR;
@property(nonatomic, strong) UIColor *separatorColor UI_APPEARANCE_SELECTOR;

@property(nonatomic, strong) UIColor *highlightedButtonColor UI_APPEARANCE_SELECTOR;

- (NSDictionary *)buttonTextAttributesForState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setButtonTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (NSDictionary *)cancelButtonTextAttributesForState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setCancelButtonTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (NSDictionary *)destructiveButtonTextAttributesForState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setDestructiveButtonTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state UI_APPEARANCE_SELECTOR;

许可证

WCActionSheet 遵循 MIT 许可证。

作者

您可以在 twitter @wczekalski 或通过 给我写信 联系我,如果您感觉友好