#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIContextualAction.h>)
//
// UIContextualAction.h
// UIKit
//
// Copyright © 2017-�2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKitDefines.h>
#import <UIKit/UIView.h>
NS_ASSUME_NONNULL_BEGIN
@class UIContextualAction;
/**
执行操作的回调
@param action 包含所选操作的信息对象
@param sourceView 来源视图(当前操作的View)
@param ^completionHandler 回调(供您在执行操作后执行;没有返回值,并采用actionPerformed属性指示是否执行了该操作,如果执行YES,未执行NO)
- 调用completionHandler将上下文重置为正常状态(例:当滑动时,重置为未擦除状态)
- 如果实际执行了操作,则将YES传递给completionHandler,以显示成功完成的可视指示
*/
typedef void (^UIContextualActionHandler)(UIContextualAction *action, __kindof UIView *sourceView, void(^completionHandler)(BOOL actionPerformed));
/* 操作风格 <枚举> */
typedef NS_ENUM(NSInteger, UIContextualActionStyle) {
UIContextualActionStyleNormal, /// 正常操作
UIContextualActionStyleDestructive /// 删除操作(或特殊红色破坏性操作)
} NS_SWIFT_NAME(UIContextualAction.Style) API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);
#pragma mark - 左右滑动表格操作 Calss
#pragma mark -
/*
概述
- UITableViewDelegate中的UISwipeActionsConfiguration对象使用
*/
UIKIT_EXTERN API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos)
@interface UIContextualAction : NSObject
/**
实例化
@param style 操作风格
@param title 标题
@param handler 执行操作的回调
@return UIContextualAction
*/
+ (instancetype)contextualActionWithStyle:(UIContextualActionStyle)style title:(nullable NSString *)title handler:(UIContextualActionHandler)handler;
/// 操作风格
@property (nonatomic, readonly) UIContextualActionStyle style;
/// 执行操作的回调
@property (nonatomic, copy, readonly) UIContextualActionHandler handler;
/// 操作按钮上显示的文字
@property (nonatomic, copy, nullable) NSString *title;
/// 动作按钮的背景颜色(通过action style设置默认背景颜色)
@property (nonatomic, copy, null_resettable) UIColor *backgroundColor;
/// 动作按钮中的图像
@property (nonatomic, copy, nullable) UIImage *image;
@end
NS_ASSUME_NONNULL_END
#else
#import <UIKitCore/UIContextualAction.h>
#endif
网友评论