#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIEvent.h>)
//
// UIEvent.h
// UIKit
//
// Copyright (c) 2005-2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKitDefines.h>
NS_ASSUME_NONNULL_BEGIN
@class UIWindow, UIView, UIGestureRecognizer, UITouch;
/* 事件的常规类型 <枚举> */
typedef NS_ENUM(NSInteger, UIEventType) {
UIEventTypeTouches, /// 屏幕触摸事件
UIEventTypeMotion, /// 设备运动事件 (如用户摇晃手机时)
UIEventTypeRemoteControl, /// 遥控事件 (远程控制事件源自从耳机或外部附件接收的命令,用于控制设备上的多媒体)
UIEventTypePresses NS_ENUM_AVAILABLE_IOS(9_0), /// 按下物理按钮事件 (如按下Home键)
};
/* 与常规类型相关的子类型 <枚举> */
typedef NS_ENUM(NSInteger, UIEventSubtype) {
// UIEventTypeTouches的子类型;适用于iOS 3.0 //
UIEventSubtypeNone = 0, /// 空类型
// UIEventTypeMotion的子类型;适用于iOS 3.0 //
UIEventSubtypeMotionShake = 1, /// 摇晃设备
// 通过遥控事件操作音频或视频;UIEventTypeRemoteControl的子类型;适用于iOS 4.0 //
UIEventSubtypeRemoteControlPlay = 100, /// 播放
UIEventSubtypeRemoteControlPause = 101, /// 暂停
UIEventSubtypeRemoteControlStop = 102, /// 停止
UIEventSubtypeRemoteControlTogglePlayPause = 103, /// 切换播放/暂停
UIEventSubtypeRemoteControlNextTrack = 104, /// 下一曲目
UIEventSubtypeRemoteControlPreviousTrack = 105, /// 上一曲目
UIEventSubtypeRemoteControlBeginSeekingBackward = 106, /// 开始快退
UIEventSubtypeRemoteControlEndSeekingBackward = 107, /// 结束快退
UIEventSubtypeRemoteControlBeginSeekingForward = 108, /// 开始快进
UIEventSubtypeRemoteControlEndSeekingForward = 109, /// 结束快进
};
#pragma mark - 事件 Class
#pragma mark -
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIEvent : NSObject
/// 常规类型
@property(nonatomic,readonly) UIEventType type NS_AVAILABLE_IOS(3_0);
/// 与常规类型相关的子类型
@property(nonatomic,readonly) UIEventSubtype subtype NS_AVAILABLE_IOS(3_0);
/// 事件发生的时间
@property(nonatomic,readonly) NSTimeInterval timestamp;
/* 事件中的所有触摸对象 */
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly, nullable) NSSet <UITouch *> *allTouches;
#else
- (nullable NSSet <UITouch *> *)allTouches;
#endif
// 获取指定Window下的所有触摸对象
- (nullable NSSet <UITouch *> *)touchesForWindow:(UIWindow *)window;
// 获取指定View下的所有触摸对象
- (nullable NSSet <UITouch *> *)touchesForView:(UIView *)view;
// 获取指定手势识别器下的所有触摸对象
- (nullable NSSet <UITouch *> *)touchesForGestureRecognizer:(UIGestureRecognizer *)gesture NS_AVAILABLE_IOS(3_2);
// 获取指定触摸对象下的所有触摸对象(想要提高精度的App可以使用此方法来检索额外的触摸对象)
- (nullable NSArray <UITouch *> *)coalescedTouchesForTouch:(UITouch *)touch NS_AVAILABLE_IOS(9_0);
// 获取指定触摸对象下的所有预估触摸对象
- (nullable NSArray <UITouch *> *)predictedTouchesForTouch:(UITouch *)touch NS_AVAILABLE_IOS(9_0);
@end
NS_ASSUME_NONNULL_END
#else
#import <UIKitCore/UIEvent.h>
#endif
网友评论