UIDevice(FWAdaptive)

@interface UIDevice (FWAdaptive)

/// 是否是模拟器
@property (class, nonatomic, assign, readonly) BOOL fw_isSimulator NS_REFINED_FOR_SWIFT;

/// 是否是iPhone
@property (class, nonatomic, assign, readonly) BOOL fw_isIphone NS_REFINED_FOR_SWIFT;
/// 是否是iPad
@property (class, nonatomic, assign, readonly) BOOL fw_isIpad NS_REFINED_FOR_SWIFT;
/// 是否是Mac
@property (class, nonatomic, assign, readonly) BOOL fw_isMac NS_REFINED_FOR_SWIFT;

/// 界面是否横屏
@property (class, nonatomic, assign, readonly) BOOL fw_isLandscape NS_REFINED_FOR_SWIFT;
/// 设备是否横屏,无论支不支持横屏
@property (class, nonatomic, assign, readonly) BOOL fw_isDeviceLandscape NS_REFINED_FOR_SWIFT;
/// 设置界面方向,支持旋转方向时生效
+ (BOOL)fw_setDeviceOrientation:(UIDeviceOrientation)orientation NS_REFINED_FOR_SWIFT;

/// iOS系统版本
@property (class, nonatomic, assign, readonly) double fw_iosVersion NS_REFINED_FOR_SWIFT;
/// 是否是指定iOS主版本
+ (BOOL)fw_isIos:(NSInteger)version NS_REFINED_FOR_SWIFT;
/// 是否是大于等于指定iOS主版本
+ (BOOL)fw_isIosLater:(NSInteger)version NS_REFINED_FOR_SWIFT;

/// 设备尺寸,跟横竖屏无关
@property (class, nonatomic, assign, readonly) CGSize fw_deviceSize NS_REFINED_FOR_SWIFT;
/// 设备宽度,跟横竖屏无关
@property (class, nonatomic, assign, readonly) CGFloat fw_deviceWidth NS_REFINED_FOR_SWIFT;
/// 设备高度,跟横竖屏无关
@property (class, nonatomic, assign, readonly) CGFloat fw_deviceHeight NS_REFINED_FOR_SWIFT;
/// 设备分辨率,跟横竖屏无关
@property (class, nonatomic, assign, readonly) CGSize fw_deviceResolution NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 是否是模拟器

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) BOOL fw_isSimulator;
  • 是否是iPhone

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) BOOL fw_isIphone;
  • 是否是iPad

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) BOOL fw_isIpad;
  • 是否是Mac

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) BOOL fw_isMac;
  • 界面是否横屏

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) BOOL fw_isLandscape;
  • 设备是否横屏,无论支不支持横屏

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) BOOL fw_isDeviceLandscape;
  • 设置界面方向,支持旋转方向时生效

    Declaration

    Objective-C

    + (BOOL)fw_setDeviceOrientation:(UIDeviceOrientation)orientation;
  • iOS系统版本

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) double fw_iosVersion;
  • 是否是指定iOS主版本

    Declaration

    Objective-C

    + (BOOL)fw_isIos:(NSInteger)version;
  • 是否是大于等于指定iOS主版本

    Declaration

    Objective-C

    + (BOOL)fw_isIosLater:(NSInteger)version;
  • 设备尺寸,跟横竖屏无关

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) CGSize fw_deviceSize;
  • 设备宽度,跟横竖屏无关

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) CGFloat fw_deviceWidth;
  • 设备高度,跟横竖屏无关

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) CGFloat fw_deviceHeight;
  • 设备分辨率,跟横竖屏无关

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) CGSize fw_deviceResolution;

UIDevice+FWUIKit

  • 设置设备token原始Data,格式化并保存

    Declaration

    Objective-C

    + (void)fw_setDeviceTokenData:(nullable NSData *)tokenData;
  • 获取或设置设备Token格式化后的字符串

    Declaration

    Objective-C

    @property (class, nonatomic, copy, nullable) NSString *fw_deviceToken;
  • 获取设备模型,格式:"iPhone6,1"

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly, nullable) NSString *fw_deviceModel;
  • 获取设备IDFV(内部使用),同账号应用全删除后会改变,可通过keychain持久化

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly, nullable) NSString *fw_deviceIDFV;
  • 获取设备IDFA(外部使用),重置广告或系统后会改变,需先检测广告追踪权限,启用Tracking子模块后生效

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly, nullable) NSString *fw_deviceIDFA;

UIDevice+UIKit

  • 获取或设置设备UUID,自动keychain持久化。默认获取IDFV(未使用IDFA,避免额外权限),失败则随机生成一个

    Declaration

    Swift

    @objc(fw_deviceUUID)
    public static var __fw_deviceUUID: String { get set }