Categories

The following categories are available globally.

UIApplication+FWAdaptive

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIApplication (FWAdaptive)
    
    /// 是否是调试模式
    @property (class, nonatomic, assign, readonly) BOOL fw_isDebug NS_REFINED_FOR_SWIFT;
    
    @end

UIDevice+FWAdaptive

  • Undocumented

    See more

    Declaration

    Objective-C

    @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

UIScreen+FWAdaptive

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIScreen (FWAdaptive)
    
    /// 屏幕尺寸
    @property (class, nonatomic, assign, readonly) CGSize fw_screenSize NS_REFINED_FOR_SWIFT;
    /// 屏幕宽度
    @property (class, nonatomic, assign, readonly) CGFloat fw_screenWidth NS_REFINED_FOR_SWIFT;
    /// 屏幕高度
    @property (class, nonatomic, assign, readonly) CGFloat fw_screenHeight NS_REFINED_FOR_SWIFT;
    /// 屏幕像素比例
    @property (class, nonatomic, assign, readonly) CGFloat fw_screenScale NS_REFINED_FOR_SWIFT;
    /// 是否是指定英寸屏幕
    + (BOOL)fw_isScreenInch:(FWScreenInch)inch NS_REFINED_FOR_SWIFT;
    /// 是否是全面屏屏幕
    @property (class, nonatomic, assign, readonly) BOOL fw_isNotchedScreen NS_REFINED_FOR_SWIFT;
    
    /// 获取一像素的大小
    @property (class, nonatomic, assign, readonly) CGFloat fw_pixelOne NS_REFINED_FOR_SWIFT;
    /// 检查是否含有安全区域,可用来判断iPhoneX
    @property (class, nonatomic, assign, readonly) BOOL fw_hasSafeAreaInsets NS_REFINED_FOR_SWIFT;
    /// 获取安全区域距离
    @property (class, nonatomic, assign, readonly) UIEdgeInsets fw_safeAreaInsets NS_REFINED_FOR_SWIFT;
    
    /// 状态栏高度,与是否隐藏无关
    @property (class, nonatomic, assign, readonly) CGFloat fw_statusBarHeight NS_REFINED_FOR_SWIFT;
    /// 导航栏高度,与是否隐藏无关
    @property (class, nonatomic, assign, readonly) CGFloat fw_navigationBarHeight NS_REFINED_FOR_SWIFT;
    /// 顶部栏高度,包含状态栏、导航栏,与是否隐藏无关
    @property (class, nonatomic, assign, readonly) CGFloat fw_topBarHeight NS_REFINED_FOR_SWIFT;
    /// 标签栏高度,与是否隐藏无关
    @property (class, nonatomic, assign, readonly) CGFloat fw_tabBarHeight NS_REFINED_FOR_SWIFT;
    /// 工具栏高度,与是否隐藏无关
    @property (class, nonatomic, assign, readonly) CGFloat fw_toolBarHeight NS_REFINED_FOR_SWIFT;
    
    /// 指定等比例缩放参考设计图尺寸,默认{375,812},宽度常用
    @property (class, nonatomic, assign) CGSize fw_referenceSize NS_REFINED_FOR_SWIFT;
    /// 获取当前屏幕宽度缩放比例,宽度常用
    @property (class, nonatomic, assign, readonly) CGFloat fw_relativeScale NS_REFINED_FOR_SWIFT;
    /// 获取当前屏幕高度缩放比例,高度不常用
    @property (class, nonatomic, assign, readonly) CGFloat fw_relativeHeightScale NS_REFINED_FOR_SWIFT;
    
    /// 获取相对设计图宽度等比例缩放值
    + (CGFloat)fw_relativeValue:(CGFloat)value NS_REFINED_FOR_SWIFT;
    
    /// 获取相对设计图高度等比例缩放值
    + (CGFloat)fw_relativeHeight:(CGFloat)value NS_REFINED_FOR_SWIFT;
    
    /// 获取相对设计图宽度等比例缩放时的固定宽度值
    + (CGFloat)fw_fixedValue:(CGFloat)value NS_REFINED_FOR_SWIFT;
    
    /// 获取相对设计图高度等比例缩放时的固定高度值
    + (CGFloat)fw_fixedHeight:(CGFloat)value NS_REFINED_FOR_SWIFT;
    
    /// 基于当前设备的屏幕倍数,对传进来的floatValue进行像素取整
    + (CGFloat)fw_flatValue:(CGFloat)value NS_REFINED_FOR_SWIFT;
    
    /// 基于指定的倍数(0取当前设备),对传进来的floatValue进行像素取整
    + (CGFloat)fw_flatValue:(CGFloat)value scale:(CGFloat)scale NS_REFINED_FOR_SWIFT;
    
    @end

UIView+FWAdaptive

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIView (FWAdaptive)
    
    /// 是否自动等比例缩放方式设置transform,默认NO
    @property (nonatomic, assign) BOOL fw_autoScaleTransform NS_REFINED_FOR_SWIFT;
    
    @end

UIViewController+FWAdaptive

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIViewController (FWAdaptive)
    
    /// 当前状态栏布局高度,导航栏隐藏时为0,推荐使用
    @property (nonatomic, assign, readonly) CGFloat fw_statusBarHeight NS_REFINED_FOR_SWIFT;
    
    /// 当前导航栏布局高度,隐藏时为0,推荐使用
    @property (nonatomic, assign, readonly) CGFloat fw_navigationBarHeight NS_REFINED_FOR_SWIFT;
    
    /// 当前顶部栏布局高度,导航栏隐藏时为0,推荐使用
    @property (nonatomic, assign, readonly) CGFloat fw_topBarHeight NS_REFINED_FOR_SWIFT;
    
    /// 当前标签栏布局高度,隐藏时为0,推荐使用
    @property (nonatomic, assign, readonly) CGFloat fw_tabBarHeight NS_REFINED_FOR_SWIFT;
    
    /// 当前工具栏布局高度,隐藏时为0,推荐使用
    @property (nonatomic, assign, readonly) CGFloat fw_toolBarHeight NS_REFINED_FOR_SWIFT;
    
    /// 当前底部栏布局高度,包含标签栏和工具栏,隐藏时为0,推荐使用
    @property (nonatomic, assign, readonly) CGFloat fw_bottomBarHeight NS_REFINED_FOR_SWIFT;
    
    @end

UIAlertAction+FWAlert

  • 系统弹出框动作分类,自定义属性

    Note

    系统弹出动作title仅支持NSString,如果需要支持NSAttributedString等,请使用FWAlertController
    See more

    Declaration

    Objective-C

    @interface UIAlertAction (FWAlert)

UIAlertController+FWAlert

  • 系统弹出框控制器分类,自定义样式

    Note

    系统弹出框title和message仅支持NSString,如果需要支持NSAttributedString等,请使用FWAlertController
    See more

    Declaration

    Objective-C

    @interface UIAlertController (FWAlert)

UIImage+FWAnimated

NSData+FWAnimated

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSData (FWAnimated)
    
    /// 获取图片数据的格式,未知格式返回FWImageFormatUndefined
    + (FWImageFormat)fw_imageFormatForImageData:(nullable NSData *)data NS_REFINED_FOR_SWIFT;
    
    /// 图片格式转化为UTType,未知格式返回kUTTypeImage
    + (nonnull CFStringRef)fw_UTTypeFromImageFormat:(FWImageFormat)format CF_RETURNS_NOT_RETAINED NS_REFINED_FOR_SWIFT;
    
    /// UTType转化为图片格式,未知格式返回FWImageFormatUndefined
    + (FWImageFormat)fw_imageFormatFromUTType:(nonnull CFStringRef)uttype NS_REFINED_FOR_SWIFT;
    
    /// 图片格式转化为mimeType,未知格式返回application/octet-stream
    + (NSString *)fw_mimeTypeFromImageFormat:(FWImageFormat)format NS_REFINED_FOR_SWIFT;
    
    /// 文件后缀转化为mimeType,未知后缀返回application/octet-stream
    + (NSString *)fw_mimeTypeFromExtension:(NSString *)extension NS_REFINED_FOR_SWIFT;
    
    /// 图片数据编码为base64字符串,可直接用于H5显示等,字符串格式:data:image/png;base64,数据
    + (nullable NSString *)fw_base64StringForImageData:(nullable NSData *)data NS_REFINED_FOR_SWIFT;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSObject (FWAppearance)
    
    /// 从 appearance 里取值并赋值给当前实例,通常在对象的 init 里调用
    - (void)fw_applyAppearance NS_REFINED_FOR_SWIFT;
    
    @end

FWAssetManager

NSMutableAttributedString+FWAttributedLabel

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSMutableAttributedString (FWAttributedLabel)
    
    @property (nonatomic, strong, nullable) UIColor *fw_textColor NS_REFINED_FOR_SWIFT;
    - (void)fw_setTextColor:(UIColor*)color range:(NSRange)range NS_REFINED_FOR_SWIFT;
    
    @property (nonatomic, strong, nullable) UIFont *fw_font NS_REFINED_FOR_SWIFT;
    - (void)fw_setFont:(UIFont*)font range:(NSRange)range NS_REFINED_FOR_SWIFT;
    
    - (void)fw_setUnderlineStyle:(CTUnderlineStyle)style
                       modifier:(CTUnderlineStyleModifiers)modifier NS_REFINED_FOR_SWIFT;
    - (void)fw_setUnderlineStyle:(CTUnderlineStyle)style
                       modifier:(CTUnderlineStyleModifiers)modifier
                          range:(NSRange)range NS_REFINED_FOR_SWIFT;
    
    @end

NSLayoutConstraint+FWAutoLayout

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSLayoutConstraint (FWAutoLayout)
    
    /// 标记是否是相反的约束,一般相对于父视图
    @property (nonatomic, assign) BOOL fw_isOpposite NS_REFINED_FOR_SWIFT;
    
    /// 设置内间距值,如果是相反的约束,会自动取反
    @property (nonatomic, assign) CGFloat fw_inset NS_REFINED_FOR_SWIFT;
    
    /// 安全修改优先级,防止iOS13以下已激活约束修改Required崩溃
    @property (nonatomic, assign) UILayoutPriority fw_priority NS_REFINED_FOR_SWIFT;
    
    @end

UIBarItem+FWBadge

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIBarItem (FWBadge)
    
    /// 获取UIBarItem(UIBarButtonItem、UITabBarItem)内部的view,通常对于navigationItem和tabBarItem而言,需要在设置为item后并且在bar可见时(例如 viewDidAppear:及之后)获取fwView才有值
    @property (nullable, nonatomic, weak, readonly) UIView *fw_view NS_REFINED_FOR_SWIFT;
    
    /// 当item内的view生成后就会调用一次这个block,仅对UIBarButtonItem、UITabBarItem有效
    @property (nullable, nonatomic, copy) void (^fw_viewLoadedBlock)(__kindof UIBarItem *item, UIView *view) NS_REFINED_FOR_SWIFT;
    
    @end

UIBarButtonItem+FWBadge

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIBarButtonItem (FWBadge)
    
    /// 显示右上角提醒灯,上右偏移指定距离
    - (void)fw_showBadgeView:(FWBadgeView *)badgeView badgeValue:(nullable NSString *)badgeValue NS_REFINED_FOR_SWIFT;
    
    /// 隐藏提醒灯
    - (void)fw_hideBadgeView NS_REFINED_FOR_SWIFT;
    
    @end

UITabBarItem+FWBadge

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UITabBarItem (FWBadge)
    
    /// 获取一个UITabBarItem内显示图标的UIImageView,如果找不到则返回nil
    @property (nullable, nonatomic, weak, readonly) UIImageView *fw_imageView NS_REFINED_FOR_SWIFT;
    
    /// 显示右上角提醒灯,上右偏移指定距离
    - (void)fw_showBadgeView:(FWBadgeView *)badgeView badgeValue:(nullable NSString *)badgeValue NS_REFINED_FOR_SWIFT;
    
    /// 隐藏提醒灯
    - (void)fw_hideBadgeView NS_REFINED_FOR_SWIFT;
    
    @end

UINavigationBar+FWBarAppearance

  • 导航栏视图分类,全局设置用[UINavigationBar appearance]。默认iOS15+启用appearance,iOS14及以下使用旧版本api

    See more

    Declaration

    Objective-C

    @interface UINavigationBar (FWBarAppearance)

UITabBar+FWBarAppearance

  • 标签栏视图分类,全局设置用[UITabBar appearance]。iOS15+启用appearance,iOS14及以下使用旧版本api

    See more

    Declaration

    Objective-C

    @interface UITabBar (FWBarAppearance)

UIToolbar+FWBarAppearance

  • 工具栏样式分类,全局设置用[UIToolbar appearance]。iOS15+启用appearance,iOS14及以下使用旧版本api

    Note

    工具栏高度建议用sizeToFit自动获取(示例44),contentView为内容视图(示例44),backgroundView为背景视图(示例78)
    See more

    Declaration

    Objective-C

    @interface UIToolbar (FWBarAppearance)

NSTimer+FWBlock

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSTimer (FWBlock)
    
    /**
     创建NSTimer,使用target-action,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
     
     @param seconds 时间
     @param target 目标
     @param selector 方法
     @param userInfo 参数
     @param repeats 是否重复
     @return 定时器
     */
    + (NSTimer *)fw_commonTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)selector userInfo:(nullable id)userInfo repeats:(BOOL)repeats NS_REFINED_FOR_SWIFT;
    
    /**
     创建NSTimer,使用block,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
     
     @param seconds 时间
     @param block 代码块
     @param repeats 是否重复
     @return 定时器
     */
    + (NSTimer *)fw_commonTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats NS_REFINED_FOR_SWIFT;
    
    /**
     创建倒计时定时器
     
     @param seconds 倒计时描述
     @param block 每秒执行block,为0时自动停止
     @return 定时器,可手工停止
     */
    + (NSTimer *)fw_commonTimerWithCountDown:(NSInteger)seconds block:(void (^)(NSInteger countDown))block NS_REFINED_FOR_SWIFT;
    
    /**
     创建NSTimer,使用block,需要调用addTimer:forMode:安排到当前的运行循环中(CommonModes避免ScrollView滚动时不触发)。
     @note 示例:[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]
     
     @param seconds 时间
     @param block 代码块
     @param repeats 是否重复
     @return 定时器
     */
    + (NSTimer *)fw_timerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats NS_REFINED_FOR_SWIFT;
    
    /**
     创建NSTimer,使用block,默认模式安排到当前的运行循环中
     
     @param seconds 时间
     @param block 代码块
     @param repeats 是否重复
     @return 定时器
     */
    + (NSTimer *)fw_scheduledTimerWithTimeInterval:(NSTimeInterval)seconds block:(void (^)(NSTimer *timer))block repeats:(BOOL)repeats NS_REFINED_FOR_SWIFT;
    
    /// 暂停NSTimer
    - (void)fw_pauseTimer NS_REFINED_FOR_SWIFT;
    
    /// 开始NSTimer
    - (void)fw_resumeTimer NS_REFINED_FOR_SWIFT;
    
    /// 延迟delay秒后开始NSTimer
    - (void)fw_resumeTimerAfterDelay:(NSTimeInterval)delay NS_REFINED_FOR_SWIFT;
    
    @end

UIGestureRecognizer+FWBlock

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIGestureRecognizer (FWBlock)
    
    /// 添加事件句柄,返回唯一标志
    - (NSString *)fw_addBlock:(void (^)(id sender))block NS_REFINED_FOR_SWIFT;
    
    /// 根据唯一标志移除事件句柄
    - (void)fw_removeBlock:(nullable NSString *)identifier NS_REFINED_FOR_SWIFT;
    
    /// 移除所有事件句柄
    - (void)fw_removeAllBlocks NS_REFINED_FOR_SWIFT;
    
    /// 从事件句柄初始化
    + (instancetype)fw_gestureRecognizerWithBlock:(void (^)(id sender))block NS_REFINED_FOR_SWIFT;
    
    @end

UIControl+FWBlock

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIControl (FWBlock)
    
    /// 添加事件句柄
    - (NSString *)fw_addBlock:(void (^)(id sender))block forControlEvents:(UIControlEvents)controlEvents NS_REFINED_FOR_SWIFT;
    
    /// 根据唯一标志移除事件句柄
    - (void)fw_removeBlock:(nullable NSString *)identifier forControlEvents:(UIControlEvents)controlEvents NS_REFINED_FOR_SWIFT;
    
    /// 移除所有事件句柄
    - (void)fw_removeAllBlocksForControlEvents:(UIControlEvents)controlEvents NS_REFINED_FOR_SWIFT;
    
    /// 添加点击事件
    - (void)fw_addTouchTarget:(id)target action:(SEL)action NS_REFINED_FOR_SWIFT;
    
    /// 添加点击句柄
    - (NSString *)fw_addTouchBlock:(void (^)(id sender))block NS_REFINED_FOR_SWIFT;
    
    /// 根据唯一标志移除点击句柄
    - (void)fw_removeTouchBlock:(nullable NSString *)identifier NS_REFINED_FOR_SWIFT;
    
    /// 移除所有点击句柄
    - (void)fw_removeAllTouchBlocks NS_REFINED_FOR_SWIFT;
    
    @end

UIBarButtonItem+FWBlock

  • iOS11之后,customView必须具有intrinsicContentSize值才能点击,可使用frame布局或者实现intrinsicContentSize即可

    See more

    Declaration

    Objective-C

    @interface UIBarButtonItem (FWBlock)

FWCollectionViewSectionConfig

UITableViewCell+FWDynamicLayout

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UITableViewCell (FWDynamicLayout)
    
    /// 如果用来确定Cell所需高度的View是唯一的,请把此值设置为YES,可提升一定的性能
    @property (nonatomic, assign) BOOL fw_maxYViewFixed NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图的底部内边距,可避免新创建View来撑开Cell,默认0
    @property (nonatomic, assign) CGFloat fw_maxYViewPadding NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图是否撑开布局,需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
    @property (nonatomic, assign) BOOL fw_maxYViewExpanded NS_REFINED_FOR_SWIFT;
    
    /// 免注册创建UITableViewCell,内部自动处理缓冲池,默认Default类型
    + (instancetype)fw_cellWithTableView:(UITableView *)tableView NS_REFINED_FOR_SWIFT;
    
    /// 免注册alloc创建UITableViewCell,内部自动处理缓冲池,指定style类型
    + (instancetype)fw_cellWithTableView:(UITableView *)tableView
                                              style:(UITableViewCellStyle)style NS_REFINED_FOR_SWIFT;
    
    /// 免注册alloc创建UITableViewCell,内部自动处理缓冲池,指定style类型,指定reuseIdentifier
    + (instancetype)fw_cellWithTableView:(UITableView *)tableView
                                              style:(UITableViewCellStyle)style
                                    reuseIdentifier:(nullable NSString *)reuseIdentifier NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算cell高度,不使用缓存,子类可重写
    + (CGFloat)fw_heightWithTableView:(UITableView *)tableView
                     configuration:(FWCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    @end

UITableViewHeaderFooterView+FWDynamicLayout

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UITableViewHeaderFooterView (FWDynamicLayout)
    
    /// 如果用来确定HeaderFooterView所需高度的View是唯一的,请把此值设置为YES,可提升一定的性能
    @property (nonatomic, assign) BOOL fw_maxYViewFixed NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图的底部内边距,可避免新创建View来撑开HeaderFooterView,默认0
    @property (nonatomic, assign) CGFloat fw_maxYViewPadding NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图是否撑开布局,需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
    @property (nonatomic, assign) BOOL fw_maxYViewExpanded NS_REFINED_FOR_SWIFT;
    
    /// 免注册alloc创建UITableViewHeaderFooterView,内部自动处理缓冲池
    + (instancetype)fw_headerFooterViewWithTableView:(UITableView *)tableView NS_REFINED_FOR_SWIFT;
    
    /// 免注册alloc创建UITableViewHeaderFooterView,内部自动处理缓冲池,指定reuseIdentifier
    + (instancetype)fw_headerFooterViewWithTableView:(UITableView *)tableView reuseIdentifier:(nullable NSString *)reuseIdentifier NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算cell高度,不使用缓存,子类可重写
    + (CGFloat)fw_heightWithTableView:(UITableView *)tableView
                              type:(FWHeaderFooterViewType)type
                     configuration:(FWHeaderFooterViewConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    @end

UITableView+FWDynamicLayout

UICollectionViewCell+FWDynamicLayout

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UICollectionViewCell (FWDynamicLayout)
    
    /// 如果用来确定Cell所需尺寸的View是唯一的,请把此值设置为YES,可提升一定的性能
    @property (nonatomic, assign) BOOL fw_maxYViewFixed NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图的底部内边距(横向滚动时为X),可避免新创建View来撑开Cell,默认0
    @property (nonatomic, assign) CGFloat fw_maxYViewPadding NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图是否撑开布局(横向滚动时为X),需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
    @property (nonatomic, assign) BOOL fw_maxYViewExpanded NS_REFINED_FOR_SWIFT;
    
    /// 免注册创建UICollectionViewCell,内部自动处理缓冲池
    + (instancetype)fw_cellWithCollectionView:(UICollectionView *)collectionView
                                   indexPath:(NSIndexPath *)indexPath NS_REFINED_FOR_SWIFT;
    
    /// 免注册创建UICollectionViewCell,内部自动处理缓冲池,指定reuseIdentifier
    + (instancetype)fw_cellWithCollectionView:(UICollectionView *)collectionView
                                   indexPath:(NSIndexPath *)indexPath
                             reuseIdentifier:(nullable NSString *)reuseIdentifier NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算view大小,子类可重写
    + (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                       configuration:(FWCollectionCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算view大小,固定宽度,子类可重写
    + (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                               width:(CGFloat)width
                       configuration:(FWCollectionCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算view大小,固定高度,子类可重写
    + (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                              height:(CGFloat)height
                       configuration:(FWCollectionCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    @end

UICollectionReusableView+FWDynamicLayout

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UICollectionReusableView (FWDynamicLayout)
    
    /// 如果用来确定ReusableView所需尺寸的View是唯一的,请把此值设置为YES,可提升一定的性能
    @property (nonatomic, assign) BOOL fw_maxYViewFixed NS_REFINED_FOR_SWIFT;
    
    /// 最大Y尺寸视图的底部内边距(横向滚动时为X),可避免新创建View来撑开ReusableView,默认0
    @property (nonatomic, assign) CGFloat fw_maxYViewPadding NS_REFINED_FOR_SWIFT;
    
    /// 最大Y视图是否撑开布局(横向滚动时为X),需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
    @property (nonatomic, assign) BOOL fw_maxYViewExpanded NS_REFINED_FOR_SWIFT;
    
    /// 免注册alloc创建UICollectionReusableView,内部自动处理缓冲池
    + (instancetype)fw_reusableViewWithCollectionView:(UICollectionView *)collectionView
                                                kind:(NSString *)kind
                                           indexPath:(NSIndexPath *)indexPath NS_REFINED_FOR_SWIFT;
    
    /// 免注册alloc创建UICollectionReusableView,内部自动处理缓冲池,指定reuseIdentifier
    + (instancetype)fw_reusableViewWithCollectionView:(UICollectionView *)collectionView
                                                kind:(NSString *)kind
                                           indexPath:(NSIndexPath *)indexPath
                                     reuseIdentifier:(nullable NSString *)reuseIdentifier NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算view大小,子类可重写
    + (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                                kind:(NSString *)kind
                       configuration:(FWReusableViewConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算view大小,固定宽度,子类可重写
    + (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                               width:(CGFloat)width
                                kind:(NSString *)kind
                       configuration:(FWReusableViewConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    /// 根据配置自动计算view大小,固定高度,子类可重写
    + (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                              height:(CGFloat)height
                                kind:(NSString *)kind
                       configuration:(FWReusableViewConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;
    
    @end

UICollectionView+FWDynamicLayout

  • 集合自动计算并缓存cell高度分类,最底部view的MaxY即为cell高度,自定义方案实现

    如果使用系统自动尺寸,建议设置estimatedItemSize提高性能

    See more

    Declaration

    Objective-C

    @interface UICollectionView (FWDynamicLayout)

UIScrollView+FWEmptyPlugin

UIScrollView+FWScrollOverlayView

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIScrollView (FWScrollOverlayView)
    
    /// 滚动视图自定义浮层,用于显示空界面等,兼容UITableView|UICollectionView
    @property (nonatomic, strong, readonly) UIView *fw_overlayView NS_REFINED_FOR_SWIFT;
    
    /// 是否显示自定义浮层
    @property (nonatomic, assign, readonly) BOOL fw_hasOverlayView NS_REFINED_FOR_SWIFT;
    
    /// 显示自定义浮层,自动添加到滚动视图顶部、表格视图底部
    - (void)fw_showOverlayView NS_REFINED_FOR_SWIFT;
    
    /// 显示自定义浮层,执行渐变动画,自动添加到滚动视图顶部、表格视图底部
    - (void)fw_showOverlayViewAnimated:(BOOL)animated NS_REFINED_FOR_SWIFT;
    
    /// 隐藏自定义浮层,自动从滚动视图移除
    - (void)fw_hideOverlayView NS_REFINED_FOR_SWIFT;
    
    @end

NSString+FWEncode

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSString (FWEncode)
    
    #pragma mark - Json
    
    /**
     Foundation对象编码为json字符串
     
     @param object 编码对象
     @return json字符串
     */
    + (nullable NSString *)fw_jsonEncode:(id)object NS_REFINED_FOR_SWIFT;
    
    /**
     *  json字符串解码为Foundation对象
     *
     *  @return Foundation对象
     */
    - (nullable id)fw_jsonDecode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Base64
    
    /**
     *  base64编码
     *
     *  @return base64字符串
     */
    - (nullable NSString *)fw_base64Encode NS_REFINED_FOR_SWIFT;
    
    /**
     *  base64解码
     *
     *  @return 原字符串
     */
    - (nullable NSString *)fw_base64Decode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Unicode
    
    /**
     *  计算长度,中文为1,英文为0.5
     */
    - (NSUInteger)fw_unicodeLength NS_REFINED_FOR_SWIFT;
    
    /**
     *  截取字符串,中文为1,英文为0.5
     *
     *  @param length 截取长度
     */
    - (NSString *)fw_unicodeSubstring:(NSUInteger)length NS_REFINED_FOR_SWIFT;
    
    /**
     *  Unicode中文编码,将中文转换成Unicode字符串(如\u7E8C)
     *
     *  @return Unicode字符串
     */
    - (NSString *)fw_unicodeEncode NS_REFINED_FOR_SWIFT;
    
    /**
     *  Unicode中文解码,将Unicode字符串(如\u7E8C)转换成中文
     *
     *  @return 中文字符串
     */
    - (NSString *)fw_unicodeDecode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Url
    
    /**
     *  url参数编码,适用于query参数编码
     *  示例:http://test.com?id=我是中文 =>
     *       http%3A%2F%2Ftest.com%3Fid%3D%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87
     *
     *  @return url编码字符串
     */
    - (nullable NSString *)fw_urlEncodeComponent NS_REFINED_FOR_SWIFT;
    
    /**
     *  url参数解码,适用于query参数解码
     *  示例:http%3A%2F%2Ftest.com%3Fid%3D%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87 =>
     *       http://test.com?id=我是中文
     *
     *  @return 原字符串
     */
    - (nullable NSString *)fw_urlDecodeComponent NS_REFINED_FOR_SWIFT;
    
    /**
     *  url编码,适用于整个url编码
     *  示例:http://test.com?id=我是中文 =>
     *       http://test.com?id=%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87
     *
     *  @return url编码地址
     */
    - (nullable NSString *)fw_urlEncode NS_REFINED_FOR_SWIFT;
    
    /**
     *  url解码,适用于整个url解码
     *  示例:http://test.com?id=%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87 =>
     *       http://test.com?id=我是中文
     *
     *  @return 原url地址
     */
    - (nullable NSString *)fw_urlDecode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Query
    
    /**
     * 字典编码为URL参数字符串
     */
    + (NSString *)fw_queryEncode:(NSDictionary<NSString *, id> *)dictionary NS_REFINED_FOR_SWIFT;
    
    /**
     * URL参数字符串解码为字典,支持完整URL
     */
    - (NSDictionary<NSString *, NSString *> *)fw_queryDecode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Md5
    
    /**
     *  md5编码
     *
     *  @return md5字符串
     */
    - (NSString *)fw_md5Encode NS_REFINED_FOR_SWIFT;
    
    /**
     *  文件md5编码
     *
     *  @return md5字符串
     */
    - (nullable NSString *)fw_md5EncodeFile NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Helper
    
    /**
     去掉空白字符
     */
    @property (nonatomic, copy, readonly) NSString *fw_trimString NS_REFINED_FOR_SWIFT;
    
    /**
     首字母大写
     */
    @property (nonatomic, copy, readonly) NSString *fw_ucfirstString NS_REFINED_FOR_SWIFT;
    
    /**
     首字母小写
     */
    @property (nonatomic, copy, readonly) NSString *fw_lcfirstString NS_REFINED_FOR_SWIFT;
    
    /**
     驼峰转下划线
     */
    @property (nonatomic, copy, readonly) NSString *fw_underlineString NS_REFINED_FOR_SWIFT;
    
    /**
     下划线转驼峰
     */
    @property (nonatomic, copy, readonly) NSString *fw_camelString NS_REFINED_FOR_SWIFT;
    
    /**
     中文转拼音
     */
    @property (nonatomic, copy, readonly) NSString *fw_pinyinString NS_REFINED_FOR_SWIFT;
    
    /**
     中文转拼音并进行比较
     */
    - (NSComparisonResult)fw_pinyinCompare:(NSString *)string NS_REFINED_FOR_SWIFT;
    
    /**
     过滤JSON解码特殊字符
     
     兼容\uD800-\uDFFF引起JSON解码报错3840问题,不报错时无需调用
     规则:只允许以\uD800-\uDBFF高位开头,紧跟\uDC00-\uDFFF低位;其他全不允许
     参考:https://github.com/SBJson/SBJson/blob/trunk/Classes/SBJson5StreamTokeniser.m
     */
    @property (nonatomic, copy, readonly) NSString *fw_escapeJson NS_REFINED_FOR_SWIFT;
    
    /**
     转换为UTF8编码数据
     */
    @property (nonatomic, strong, readonly, nullable) NSData *fw_utf8Data NS_REFINED_FOR_SWIFT;
    
    /**
     转换为NSURL
     */
    @property (nonatomic, copy, readonly, nullable) NSURL *fw_url NS_REFINED_FOR_SWIFT;
    
    /**
     转换为NSNumber
     */
    @property (nonatomic, readonly, nullable) NSNumber *fw_number NS_REFINED_FOR_SWIFT;
    
    @end

NSData+FWEncode

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSData (FWEncode)
    
    #pragma mark - Json
    
    /**
     Foundation对象编码为json数据
     
     @param object 编码对象
     @return json数据
     */
    + (nullable NSData *)fw_jsonEncode:(id)object NS_REFINED_FOR_SWIFT;
    
    /**
     json数据解码为Foundation对象
    
     @return Foundation对象
     */
    - (nullable id)fw_jsonDecode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Base64
    
    /**
     *  base64编码
     *
     *  @return base64数据
     */
    - (NSData *)fw_base64Encode NS_REFINED_FOR_SWIFT;
    
    /**
     *  base64解码
     *
     *  @return 原数据
     */
    - (nullable NSData *)fw_base64Decode NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Helper
    
    /**
     转换为UTF8编码字符串
     
     @return UTF8编码字符串
     */
    @property (nonatomic, copy, readonly, nullable) NSString *fw_utf8String NS_REFINED_FOR_SWIFT;
    
    @end

NSURL+FWEncode

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSURL (FWEncode)
    
    /// 获取当前query的参数字典,不含空值
    @property (nonatomic, copy, readonly) NSDictionary<NSString *, NSString *> *fw_queryDictionary NS_REFINED_FOR_SWIFT;
    
    /// 获取基准URI字符串,不含path|query|fragment等,包含scheme|host|port等
    @property (nonatomic, copy, readonly, nullable) NSString *fw_baseURI NS_REFINED_FOR_SWIFT;
    
    /// 获取路径URI字符串,不含scheme|host|port等,包含path|query|fragment等
    @property (nonatomic, copy, readonly, nullable) NSString *fw_pathURI NS_REFINED_FOR_SWIFT;
    
    /// 生成URL,中文自动URL编码
    + (nullable NSURL *)fw_urlWithString:(nullable NSString *)string NS_REFINED_FOR_SWIFT;
    
    /// 生成URL,中文自动URL编码
    + (nullable NSURL *)fw_urlWithString:(nullable NSString *)string relativeTo:(nullable NSURL *)baseURL NS_REFINED_FOR_SWIFT;
    
    @end

NSArray+FWSafeType

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSArray<__covariant ObjectType> (FWSafeType)
    
    /**
     安全获取对象
     
     @param index 索引
     @return 对象
     */
    - (nullable ObjectType)fw_objectAtIndex:(NSInteger)index NS_REFINED_FOR_SWIFT;
    
    /**
     安全获取子数组
     
     @param range 范围
     @return 对象数组
     */
    - (nullable NSArray<ObjectType> *)fw_subarrayWithRange:(NSRange)range NS_REFINED_FOR_SWIFT;
    
    @end

NSMutableArray+FWSafeType

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSMutableArray<ObjectType> (FWSafeType)
    
    /**
     安全添加对象
     
     @param object 对象
     */
    - (void)fw_addObject:(nullable ObjectType)object NS_REFINED_FOR_SWIFT;
    
    /**
     安全移除指定索引对象
     
     @param index 索引
     */
    - (void)fw_removeObjectAtIndex:(NSInteger)index NS_REFINED_FOR_SWIFT;
    
    /**
     安全插入对象到指定位置
     
     @param object 对象
     @param index 索引
     */
    - (void)fw_insertObject:(nullable ObjectType)object atIndex:(NSInteger)index NS_REFINED_FOR_SWIFT;
    
    /**
     安全替换对象到指定位置
     
     @param index 索引
     @param object 对象
     */
    - (void)fw_replaceObjectAtIndex:(NSInteger)index withObject:(nullable ObjectType)object NS_REFINED_FOR_SWIFT;
    
    /**
     安全移除子数组
     
     @param range 范围
     */
    - (void)fw_removeObjectsInRange:(NSRange)range NS_REFINED_FOR_SWIFT;
    
    /**
     安全插入数组到指定位置
     
     @param objects 要插入的数组
     @param index 索引
     */
    - (void)fw_insertObjects:(nullable NSArray *)objects atIndex:(NSInteger)index NS_REFINED_FOR_SWIFT;
    
    @end

NSMutableSet+FWSafeType

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSMutableSet<ObjectType> (FWSafeType)
    
    /**
     安全添加对象
     
     @param object 对象
     */
    - (void)fw_addObject:(nullable ObjectType)object NS_REFINED_FOR_SWIFT;
    
    /**
     安全移除对象
     
     @param object 对象
     */
    - (void)fw_removeObject:(nullable ObjectType)object NS_REFINED_FOR_SWIFT;
    
    @end

NSDictionary+FWSafeType

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSDictionary<__covariant KeyType, __covariant ObjectType> (FWSafeType)
    
    /**
     安全读取对象(过滤NSNull)
     
     @param key 键名
     @return 键值
     */
    - (nullable ObjectType)fw_objectForKey:(nullable KeyType)key NS_REFINED_FOR_SWIFT;
    
    @end

NSMutableDictionary+FWSafeType

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSMutableDictionary<KeyType, ObjectType> (FWSafeType)
    
    /**
     安全移除指定键名
     
     @param key 键名
     */
    - (void)fw_removeObjectForKey:(nullable KeyType)key NS_REFINED_FOR_SWIFT;
    
    /**
     安全设置对象(过滤NSNull)
    
     @param object 键值
     @param key 键名
     */
    - (void)fw_setObject:(nullable ObjectType)object forKey:(nullable KeyType <NSCopying>)key NS_REFINED_FOR_SWIFT;
    
    @end

NSAttributedString+FWFoundation

  • 如果需要实现行内图片可点击效果,可使用UITextView添加附件或Link并实现delegate.shouldInteractWith方法即可。 注意iOS在后台运行时,如果调用NSAttributedString解析html会导致崩溃(如动态切换深色模式时在后台解析html)。解决方法是提前在前台解析好或者后台异步到下一个主线程RunLoop

    See more

    Declaration

    Objective-C

    @interface NSAttributedString (FWFoundation)

NSData+FWFoundation

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSData (FWFoundation)
    
    /// 使用NSKeyedUnarchiver解压数据
    - (nullable id)fw_unarchiveObject:(Class)clazz NS_REFINED_FOR_SWIFT;
    
    /// 使用NSKeyedArchiver压缩对象
    + (nullable NSData *)fw_archiveObject:(id)object NS_REFINED_FOR_SWIFT;
    
    /// 保存对象归档
    + (BOOL)fw_archiveObject:(id)object toFile:(NSString *)path NS_REFINED_FOR_SWIFT;
    
    /// 读取对象归档
    + (nullable id)fw_unarchiveObject:(Class)clazz withFile:(NSString *)path NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Encrypt
    
    /// 利用AES加密数据
    - (nullable NSData *)fw_AESEncryptWithKey:(NSString *)key andIV:(NSData *)iv NS_REFINED_FOR_SWIFT;
    
    /// 利用AES解密数据
    - (nullable NSData *)fw_AESDecryptWithKey:(NSString *)key andIV:(NSData *)iv NS_REFINED_FOR_SWIFT;
    
    /// 利用3DES加密数据
    - (nullable NSData *)fw_DES3EncryptWithKey:(NSString *)key andIV:(NSData *)iv NS_REFINED_FOR_SWIFT;
    
    /// 利用3DES解密数据
    - (nullable NSData *)fw_DES3DecryptWithKey:(NSString *)key andIV:(NSData *)iv NS_REFINED_FOR_SWIFT;
    
    #pragma mark - RSA
    
    /// RSA公钥加密,数据传输安全,使用默认标签,执行base64编码
    - (nullable NSData *)fw_RSAEncryptWithPublicKey:(NSString *)publicKey NS_REFINED_FOR_SWIFT;
    
    /// RSA公钥加密,数据传输安全,可自定义标签,指定base64编码
    - (nullable NSData *)fw_RSAEncryptWithPublicKey:(NSString *)publicKey andTag:(NSString *)tagName base64Encode:(BOOL)base64Encode NS_REFINED_FOR_SWIFT;
    
    /// RSA私钥解密,数据传输安全,使用默认标签,执行base64解密
    - (nullable NSData *)fw_RSADecryptWithPrivateKey:(NSString *)privateKey NS_REFINED_FOR_SWIFT;
    
    /// RSA私钥解密,数据传输安全,可自定义标签,指定base64解码
    - (nullable NSData *)fw_RSADecryptWithPrivateKey:(NSString *)privateKey andTag:(NSString *)tagName base64Decode:(BOOL)base64Decode NS_REFINED_FOR_SWIFT;
    
    /// RSA私钥加签,防篡改防否认,使用默认标签,执行base64编码
    - (nullable NSData *)fw_RSASignWithPrivateKey:(NSString *)privateKey NS_REFINED_FOR_SWIFT;
    
    /// RSA私钥加签,防篡改防否认,可自定义标签,指定base64编码
    - (nullable NSData *)fw_RSASignWithPrivateKey:(NSString *)privateKey andTag:(NSString *)tagName base64Encode:(BOOL)base64Encode NS_REFINED_FOR_SWIFT;
    
    /// RSA公钥验签,防篡改防否认,使用默认标签,执行base64解密
    - (nullable NSData *)fw_RSAVerifyWithPublicKey:(NSString *)publicKey NS_REFINED_FOR_SWIFT;
    
    /// RSA公钥验签,防篡改防否认,可自定义标签,指定base64解码
    - (nullable NSData *)fw_RSAVerifyWithPublicKey:(NSString *)publicKey andTag:(NSString *)tagName base64Decode:(BOOL)base64Decode NS_REFINED_FOR_SWIFT;
    
    @end

NSDate+FWFoundation

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSDate (FWFoundation)
    
    /// 转化为字符串,默认当前时区,格式:yyyy-MM-dd HH:mm:ss
    @property (nonatomic, copy, readonly) NSString *fw_stringValue NS_REFINED_FOR_SWIFT;
    
    /// 转化为字符串,默认当前时区,自定义格式
    - (NSString *)fw_stringWithFormat:(NSString *)format NS_REFINED_FOR_SWIFT;
    
    /// 转化为字符串,自定义格式和时区
    - (NSString *)fw_stringWithFormat:(NSString *)format timeZone:(nullable NSTimeZone *)timeZone NS_REFINED_FOR_SWIFT;
    
    /// 当前时间戳,没有设置过返回本地时间戳,可同步设置服务器时间戳,同步后调整手机时间不影响
    @property (class, nonatomic, assign) NSTimeInterval fw_currentTime NS_REFINED_FOR_SWIFT;
    
    /// 从字符串初始化日期,默认当前时区,格式:yyyy-MM-dd HH:mm:ss
    + (nullable NSDate *)fw_dateWithString:(NSString *)string NS_REFINED_FOR_SWIFT;
    
    /// 从字符串初始化日期,默认当前时区,自定义格式
    + (nullable NSDate *)fw_dateWithString:(NSString *)string format:(NSString *)format NS_REFINED_FOR_SWIFT;
    
    /// 从字符串初始化日期,自定义格式和时区
    + (nullable NSDate *)fw_dateWithString:(NSString *)string format:(NSString *)format timeZone:(nullable NSTimeZone *)timeZone NS_REFINED_FOR_SWIFT;
    
    /// 格式化时长,格式"00:00"或"00:00:00"
    + (NSString *)fw_formatDuration:(NSTimeInterval)duration hasHour:(BOOL)hasHour NS_REFINED_FOR_SWIFT;
    
    /// 格式化16位、13位时间戳为10位(秒)
    + (NSTimeInterval)fw_formatTimestamp:(NSTimeInterval)timestamp NS_REFINED_FOR_SWIFT;
    
    /// 是否是闰年
    @property (nonatomic, assign, readonly) BOOL fw_isLeapYear NS_REFINED_FOR_SWIFT;
    
    /// 是否是同一天
    - (BOOL)fw_isSameDay:(NSDate *)date NS_REFINED_FOR_SWIFT;
    
    /// 添加指定日期,如year:1|month:-1|day:1等
    - (nullable NSDate *)fw_dateByAdding:(NSDateComponents *)components NS_REFINED_FOR_SWIFT;
    
    /// 与指定日期相隔天数
    - (NSInteger)fw_daysFrom:(NSDate *)date NS_REFINED_FOR_SWIFT;
    
    @end

NSNumber+FWFoundation

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSNumber (FWFoundation)
    
    /// 转换为CGFloat
    @property (nonatomic, assign, readonly) CGFloat fw_CGFloatValue NS_REFINED_FOR_SWIFT;
    
    /// 四舍五入,去掉末尾0,最多digit位,小数分隔符为.,分组分隔符为空,示例:12345.6789 => 12345.68
    - (NSString *)fw_roundString:(NSInteger)digit NS_REFINED_FOR_SWIFT;
    
    /// 取上整,去掉末尾0,最多digit位,小数分隔符为.,分组分隔符为空,示例:12345.6789 => 12345.68
    - (NSString *)fw_ceilString:(NSInteger)digit NS_REFINED_FOR_SWIFT;
    
    /// 取下整,去掉末尾0,最多digit位,小数分隔符为.,分组分隔符为空,示例:12345.6789 => 12345.67
    - (NSString *)fw_floorString:(NSInteger)digit NS_REFINED_FOR_SWIFT;
    
    /// 四舍五入,去掉末尾0,最多digit位,示例:12345.6789 => 12345.68
    - (NSNumber *)fw_roundNumber:(NSUInteger)digit NS_REFINED_FOR_SWIFT;
    
    /// 取上整,去掉末尾0,最多digit位,示例:12345.6789 => 12345.68
    - (NSNumber *)fw_ceilNumber:(NSUInteger)digit NS_REFINED_FOR_SWIFT;
    
    /// 取下整,去掉末尾0,最多digit位,示例:12345.6789 => 12345.67
    - (NSNumber *)fw_floorNumber:(NSUInteger)digit NS_REFINED_FOR_SWIFT;
    
    @end

NSFileManager+FWFoundation

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSFileManager (FWFoundation)
    
    /// 搜索路径,参数为NSSearchPathDirectory
    + (NSString *)fw_pathSearch:(NSSearchPathDirectory)directory NS_REFINED_FOR_SWIFT;
    
    /// 沙盒路径
    @property (class, nonatomic, copy, readonly) NSString *fw_pathHome NS_REFINED_FOR_SWIFT;
    
    /// 文档路径,iTunes会同步备份
    @property (class, nonatomic, copy, readonly) NSString *fw_pathDocument NS_REFINED_FOR_SWIFT;
    
    /// 缓存路径,系统不会删除,iTunes会删除
    @property (class, nonatomic, copy, readonly) NSString *fw_pathCaches NS_REFINED_FOR_SWIFT;
    
    /// Library路径
    @property (class, nonatomic, copy, readonly) NSString *fw_pathLibrary NS_REFINED_FOR_SWIFT;
    
    /// 配置路径,配置文件保存位置
    @property (class, nonatomic, copy, readonly) NSString *fw_pathPreference NS_REFINED_FOR_SWIFT;
    
    /// 临时路径,App退出后可能会删除
    @property (class, nonatomic, copy, readonly) NSString *fw_pathTmp NS_REFINED_FOR_SWIFT;
    
    /// bundle路径,不可写
    @property (class, nonatomic, copy, readonly) NSString *fw_pathBundle NS_REFINED_FOR_SWIFT;
    
    /// 资源路径,不可写
    @property (class, nonatomic, copy, readonly) NSString *fw_pathResource NS_REFINED_FOR_SWIFT;
    
    /// 获取目录大小,单位:B
    + (unsigned long long)fw_folderSize:(NSString *)folderPath NS_REFINED_FOR_SWIFT;
    
    @end

NSURL+FWFoundation

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSURL (FWFoundation)
    
    /**
     生成苹果地图地址外部URL
     
     @param addr 显示地址,格式latitude,longitude或搜索地址
     @param options 可选附加参数,如@{@"ll": @"latitude,longitude", @"z": @"14"}
     @return NSURL
     */
    + (nullable NSURL *)fw_appleMapsURLWithAddr:(nullable NSString *)addr options:(nullable NSDictionary *)options NS_REFINED_FOR_SWIFT;
    
    /**
     生成苹果地图导航外部URL
     
     @param saddr 导航起始点,格式latitude,longitude或搜索地址
     @param daddr 导航结束点,格式latitude,longitude或搜索地址
     @param options 可选附加参数,如@{@"ll": @"latitude,longitude", @"z": @"14"}
     @return NSURL
     */
    + (nullable NSURL *)fw_appleMapsURLWithSaddr:(nullable NSString *)saddr daddr:(nullable NSString *)daddr options:(nullable NSDictionary *)options NS_REFINED_FOR_SWIFT;
    
    /**
     生成谷歌地图外部URL,URL SCHEME为:comgooglemaps
     
     @param addr 显示地址,格式latitude,longitude或搜索地址
     @param options 可选附加参数,如@{@"center": @"latitude,longitude", @"zoom": @"14"}
     @return NSURL
     */
    + (nullable NSURL *)fw_googleMapsURLWithAddr:(nullable NSString *)addr options:(nullable NSDictionary *)options NS_REFINED_FOR_SWIFT;
    
    /**
     生成谷歌地图导航外部URL,URL SCHEME为:comgooglemaps
     
     @param saddr 导航起始点,格式latitude,longitude或搜索地址
     @param daddr 导航结束点,格式latitude,longitude或搜索地址
     @param mode 导航模式,支持driving|transit|bicycling|walking,默认driving
     @param options 可选附加参数,如@{@"center": @"latitude,longitude", @"zoom": @"14", @"dirflg": @"t,h"}
     @return NSURL
     */
    + (nullable NSURL *)fw_googleMapsURLWithSaddr:(nullable NSString *)saddr daddr:(nullable NSString *)daddr mode:(nullable NSString *)mode options:(nullable NSDictionary *)options NS_REFINED_FOR_SWIFT;
    
    /**
     生成百度地图外部URL,URL SCHEME为:baidumap
     
     @param addr 显示地址,格式latitude,longitude或搜索地址
     @param options 可选附加参数,如@{@"src": @"app", @"zoom": @"14", @"coord_type": @"默认gcj02|wgs84|bd09ll"}
     @return NSURL
     */
    + (nullable NSURL *)fw_baiduMapsURLWithAddr:(nullable NSString *)addr options:(nullable NSDictionary *)options NS_REFINED_FOR_SWIFT;
    
    /**
     生成百度地图导航外部URL,URL SCHEME为:baidumap
     
     @param saddr 导航起始点,格式latitude,longitude或搜索地址
     @param daddr 导航结束点,格式latitude,longitude或搜索地址
     @param mode 导航模式,支持driving|transit|navigation|riding|walking,默认driving
     @param options 可选附加参数,如@{@"src": @"app", @"zoom": @"14", @"coord_type": @"默认gcj02|wgs84|bd09ll"}
     @return NSURL
     */
    + (nullable NSURL *)fw_baiduMapsURLWithSaddr:(nullable NSString *)saddr daddr:(nullable NSString *)daddr mode:(nullable NSString *)mode options:(nullable NSDictionary *)options NS_REFINED_FOR_SWIFT;
    
    @end

NSUserDefaults+FWFoundation

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface NSUserDefaults (FWFoundation)
    
    /// 读取对象,支持unarchive对象
    - (nullable id)fw_objectForKey:(NSString *)key NS_REFINED_FOR_SWIFT;
    
    /// 保存对象,支持archive对象
    - (void)fw_setObject:(nullable id)object forKey:(NSString *)key NS_REFINED_FOR_SWIFT;
    
    /// 从standard读取对象,支持unarchive对象
    + (nullable id)fw_objectForKey:(NSString *)key NS_REFINED_FOR_SWIFT;
    
    /// 保存对象到standard,支持archive对象
    + (void)fw_setObject:(nullable id)object forKey:(NSString *)key NS_REFINED_FOR_SWIFT;
    
    @end
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImage (FWCropRotate)
    
    - (nonnull UIImage *)fw_croppedImageWithFrame:(CGRect)frame angle:(NSInteger)angle circularClip:(BOOL)circular NS_REFINED_FOR_SWIFT;
    
    @end

UIImagePickerController+FWImagePickerPluginImpl

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImagePickerController (FWImagePickerPluginImpl)
    
    /**
     快速创建单选照片选择器(仅图片),自动设置delegate
     
     @param sourceType 选择器类型
     @param allowsEditing 是否允许编辑
     @param completion 完成回调。参数1为图片,2为信息字典,3为是否取消
     @return 照片选择器,不支持的返回nil
     */
    + (nullable UIImagePickerController *)fw_pickerControllerWithSourceType:(UIImagePickerControllerSourceType)sourceType
                                                allowsEditing:(BOOL)allowsEditing
                                                   completion:(void (^)(UIImage * _Nullable image, NSDictionary * _Nullable info, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建单选照片选择器,可自定义dismiss流程,自动设置delegate
     
     @param sourceType 选择器类型
     @param filterType 过滤类型,默认0同系统
     @param allowsEditing 是否允许编辑
     @param shouldDismiss 是否先关闭照片选择器再回调,如果先关闭则回调参数1为nil
     @param completion 完成回调。参数1为照片选择器,2为对象(UIImage|PHLivePhoto|NSURL),3为信息字典,4为是否取消
     @return 照片选择器,不支持的返回nil
     */
    + (nullable UIImagePickerController *)fw_pickerControllerWithSourceType:(UIImagePickerControllerSourceType)sourceType
                                                   filterType:(FWImagePickerFilterType)filterType
                                                allowsEditing:(BOOL)allowsEditing
                                                shouldDismiss:(BOOL)shouldDismiss
                                                   completion:(void (^)(UIImagePickerController * _Nullable picker, id _Nullable object, NSDictionary * _Nullable info, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建单选照片选择器,使用自定义裁剪控制器编辑
     
     @param sourceType 选择器类型
     @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器
     @param completion 完成回调。参数1为图片,2为信息字典,3为是否取消
     @return 照片选择器,不支持的返回nil
     */
    + (nullable UIImagePickerController *)fw_pickerControllerWithSourceType:(UIImagePickerControllerSourceType)sourceType
                                               cropController:(nullable FWImageCropController * (^)(UIImage *image))cropController
                                                   completion:(void (^)(UIImage * _Nullable image, NSDictionary * _Nullable info, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    @end

PHPickerViewController+FWImagePickerPluginImpl

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface PHPickerViewController (FWImagePickerPluginImpl)
    
    /**
     快速创建多选照片选择器(仅图片),自动设置delegate
     
     @param selectionLimit 最大选择数量
     @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消
     @return 照片选择器
     */
    + (PHPickerViewController *)fw_pickerControllerWithSelectionLimit:(NSInteger)selectionLimit
                                              completion:(void (^)(NSArray<UIImage *> *images, NSArray<PHPickerResult *> *results, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建多选照片选择器,可自定义dismiss流程,自动设置delegate
     @note 当选择视频时,completion回调对象为NSURL临时文件路径,使用完毕后可手工删除或等待系统自动删除
     
     @param filterType 过滤类型,默认0同系统
     @param selectionLimit 最大选择数量
     @param shouldDismiss 是否先关闭照片选择器再回调,如果先关闭则回调参数1为nil
     @param completion 完成回调,主线程。参数1为照片选择器,2为对象数组(UIImage|PHLivePhoto|NSURL),3为结果数组,4为是否取消
     @return 照片选择器
     */
    + (PHPickerViewController *)fw_pickerControllerWithFilterType:(FWImagePickerFilterType)filterType
                                      selectionLimit:(NSInteger)selectionLimit
                                       shouldDismiss:(BOOL)shouldDismiss
                                          completion:(void (^)(PHPickerViewController * _Nullable picker, NSArray *objects, NSArray<PHPickerResult *> *results, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建单选照片选择器(仅图片),使用自定义裁剪控制器编辑
     
     @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器
     @param completion 完成回调,主线程。参数1为图片,2为结果信息,3为是否取消
     @return 照片选择器
     */
    + (PHPickerViewController *)fw_pickerControllerWithCropController:(nullable FWImageCropController * (^)(UIImage *image))cropController
                                              completion:(void (^)(UIImage * _Nullable image, PHPickerResult * _Nullable result, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    @end

PHPhotoLibrary+FWImagePickerPluginImpl

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface PHPhotoLibrary (FWImagePickerPluginImpl)
    
    /**
     图片选择器选择视频时临时文件存放目录,使用完成后需自行删除
     */
    @property (class, nonatomic, copy, readonly) NSString *fw_pickerControllerVideoCachePath NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建照片选择器(仅图片)
     
     @param selectionLimit 最大选择数量,iOS14以下只支持单选
     @param allowsEditing 是否允许编辑,仅iOS14以下支持编辑
     @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消
     @return 照片选择器
     */
    + (nullable __kindof UIViewController *)fw_pickerControllerWithSelectionLimit:(NSInteger)selectionLimit
                                                                   allowsEditing:(BOOL)allowsEditing
                                                                      completion:(void (^)(NSArray<UIImage *> *images, NSArray *results, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建照片选择器,可自定义dismiss流程
     
     @param filterType 过滤类型,默认0同系统
     @param selectionLimit 最大选择数量,iOS14以下只支持单选
     @param allowsEditing 是否允许编辑,仅iOS14以下支持编辑
     @param shouldDismiss 是否先关闭照片选择器再回调,如果先关闭则回调参数1为nil
     @param completion 完成回调,主线程。参数1为照片选择器,2为对象数组(UIImage|PHLivePhoto|NSURL),3位结果数组,4为是否取消
     @return 照片选择器
     */
    + (nullable __kindof UIViewController *)fw_pickerControllerWithFilterType:(FWImagePickerFilterType)filterType
                                                              selectionLimit:(NSInteger)selectionLimit
                                                               allowsEditing:(BOOL)allowsEditing
                                                               shouldDismiss:(BOOL)shouldDismiss
                                                                  completion:(void (^)(__kindof UIViewController * _Nullable picker, NSArray *objects, NSArray *results, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    /**
     快速创建单选照片选择器(仅图片),使用自定义裁剪控制器编辑
     
     @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器
     @param completion 完成回调,主线程。参数1为图片,2为结果信息,3为是否取消
     @return 照片选择器
     */
    + (nullable __kindof UIViewController *)fw_pickerControllerWithCropController:(nullable FWImageCropController * (^)(UIImage *image))cropController
                                                                      completion:(void (^)(UIImage * _Nullable image, id _Nullable result, BOOL cancel))completion NS_REFINED_FOR_SWIFT;
    
    @end

UIImage+FWImagePlugin

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImage (FWImagePlugin)
    
    /// 根据名称加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)
    + (nullable UIImage *)fw_imageNamed:(NSString *)name NS_REFINED_FOR_SWIFT;
    
    /// 根据名称从指定bundle加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)
    + (nullable UIImage *)fw_imageNamed:(NSString *)name bundle:(nullable NSBundle *)bundle NS_REFINED_FOR_SWIFT;
    
    /// 根据名称从指定bundle加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)。支持设置图片解码选项
    + (nullable UIImage *)fw_imageNamed:(NSString *)name bundle:(nullable NSBundle *)bundle options:(nullable NSDictionary<FWImageCoderOptions, id> *)options NS_REFINED_FOR_SWIFT;
    
    /// 从图片文件路径解码创建UIImage,自动识别scale,支持动图
    + (nullable UIImage *)fw_imageWithContentsOfFile:(NSString *)path NS_REFINED_FOR_SWIFT;
    
    /// 从图片数据解码创建UIImage,scale为1,支持动图
    + (nullable UIImage *)fw_imageWithData:(nullable NSData *)data NS_REFINED_FOR_SWIFT;
    
    /// 从图片数据解码创建UIImage,指定scale,支持动图
    + (nullable UIImage *)fw_imageWithData:(nullable NSData *)data scale:(CGFloat)scale NS_REFINED_FOR_SWIFT;
    
    /// 从图片数据解码创建UIImage,指定scale,支持动图。支持设置图片解码选项
    + (nullable UIImage *)fw_imageWithData:(nullable NSData *)data scale:(CGFloat)scale options:(nullable NSDictionary<FWImageCoderOptions, id> *)options NS_REFINED_FOR_SWIFT;
    
    /// 从UIImage编码创建图片数据,支持动图
    + (nullable NSData *)fw_dataWithImage:(nullable UIImage *)image NS_REFINED_FOR_SWIFT;
    
    /// 从UIImage编码创建图片数据,支持动图。支持设置图片编码选项
    + (nullable NSData *)fw_dataWithImage:(nullable UIImage *)image options:(nullable NSDictionary<FWImageCoderOptions, id> *)options NS_REFINED_FOR_SWIFT;
    
    /// 下载网络图片并返回下载凭据
    + (nullable id)fw_downloadImage:(nullable id)url
                        completion:(void (^)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error))completion
                          progress:(nullable void (^)(double progress))progress NS_REFINED_FOR_SWIFT;
    
    /// 下载网络图片并返回下载凭据,指定option
    + (nullable id)fw_downloadImage:(nullable id)url
                           options:(FWWebImageOptions)options
                           context:(nullable NSDictionary<FWImageCoderOptions, id> *)context
                        completion:(void (^)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error))completion
                          progress:(nullable void (^)(double progress))progress NS_REFINED_FOR_SWIFT;
    
    /// 指定下载凭据取消网络图片下载
    + (void)fw_cancelImageDownload:(nullable id)receipt NS_REFINED_FOR_SWIFT;
    
    @end

UIImageView+FWImagePlugin

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImageView (FWImagePlugin)
    
    /// 自定义图片插件,未设置时自动从插件池加载
    @property (nonatomic, strong, nullable) id<FWImagePlugin> fw_imagePlugin NS_REFINED_FOR_SWIFT;
    
    /// 当前正在加载的网络图片URL
    @property (nonatomic, copy, readonly, nullable) NSURL *fw_imageURL NS_REFINED_FOR_SWIFT;
    
    /// 加载网络图片,优先加载插件,默认使用框架网络库
    - (void)fw_setImageWithURL:(nullable id)url NS_REFINED_FOR_SWIFT;
    
    /// 加载网络图片,支持占位,优先加载插件,默认使用框架网络库
    - (void)fw_setImageWithURL:(nullable id)url
             placeholderImage:(nullable UIImage *)placeholderImage NS_REFINED_FOR_SWIFT;
    
    /// 加载网络图片,支持占位和回调,优先加载插件,默认使用框架网络库
    - (void)fw_setImageWithURL:(nullable id)url
             placeholderImage:(nullable UIImage *)placeholderImage
                   completion:(nullable void (^)(UIImage * _Nullable image, NSError * _Nullable error))completion NS_REFINED_FOR_SWIFT;
    
    /// 加载网络图片,支持占位、选项、回调和进度,优先加载插件,默认使用框架网络库
    - (void)fw_setImageWithURL:(nullable id)url
             placeholderImage:(nullable UIImage *)placeholderImage
                      options:(FWWebImageOptions)options
                      context:(nullable NSDictionary<FWImageCoderOptions, id> *)context
                   completion:(nullable void (^)(UIImage * _Nullable image, NSError * _Nullable error))completion
                     progress:(nullable void (^)(double progress))progress NS_REFINED_FOR_SWIFT;
    
    /// 取消加载网络图片请求
    - (void)fw_cancelImageRequest NS_REFINED_FOR_SWIFT;
    
    /// 创建动画ImageView视图,优先加载插件,默认UIImageView
    + (UIImageView *)fw_animatedImageView NS_SWIFT_NAME(__fw_animatedImageView()) NS_REFINED_FOR_SWIFT;
    
    @end

UITextField+FWKeyboard

UITextView+FWKeyboard

NSBundle+FWLanguage

  • NSBundle系统语言分类,处理mainBundle语言。如果需要处理三方SDK和系统组件语言,详见Bundle分类

    Note

    如果系统组件无法正确显示语言,需Info.plist设置CFBundleAllowMixedLocalizations为YES,从而允许应用程序获取框架库内语言。 如果key为nil,value为nil,返回空串;key为nil,value非nil,返回value;如果key不存在,value为nil或空,返回key;如果key不存在,value非空,返回value 当前使用修改bundle类方式实现,也可以使用动态替换localizedStringForKey方法来实现,但需注意此方式的性能
    See more

    Declaration

    Objective-C

    @interface NSBundle (FWLanguage)

UINavigationController+FWBarTransition

  • 优化导航栏转场动画闪烁的问题,默认关闭。全局启用后各个ViewController管理自己的导航栏样式,在viewDidLoad或viewViewAppear中设置即可

    Note

    方案1:自己实现UINavigationController管理器;方案2:将原有导航栏设置透明,每个控制器添加一个NavigationBar充当导航栏;方案3:转场开始隐藏原有导航栏并添加假的NavigationBar,转场结束后还原。此处采用方案3。更多介绍:https://tech.meituan.com/2018/10/25/navigation-transition-solution-and-best-practice-in-meituan.html

    See more

    Declaration

    Objective-C

    @interface UINavigationController (FWBarTransition)
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UINavigationBar (FWBarTransition)
    
    /// 导航栏背景视图,显示背景色和背景图片等
    @property (nonatomic, readonly, nullable) UIView *fw_backgroundView NS_REFINED_FOR_SWIFT;
    
    /// 导航栏内容视图,iOS11+才存在,显示item和titleView等
    @property (nonatomic, readonly, nullable) UIView *fw_contentView NS_REFINED_FOR_SWIFT;
    
    /// 导航栏大标题视图,显示时才有值。如果要设置背景色,可使用fwBackgroundView.backgroundColor
    @property (nonatomic, readonly, nullable) UIView *fw_largeTitleView NS_REFINED_FOR_SWIFT;
    
    /// 导航栏大标题高度,与是否隐藏无关
    @property (class, nonatomic, readonly, assign) CGFloat fw_largeTitleHeight NS_REFINED_FOR_SWIFT;
    
    @end
  • present带导航栏webview,如果存在input[type=file],会dismiss两次,无法选择照片。 解决方法:1.使用push 2.重写dismiss方法仅当presentedViewController存在时才调用dismiss

    See more

    Declaration

    Objective-C

    @interface UIToolbar (FWBarTransition)

UINavigationController+FWFullscreenPopGesture

UINavigationBar+FWStyle

UIWindow+FWNavigator

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIWindow (FWNavigator)
    
    /// 获取当前主window,可自定义
    @property (class, nonatomic, readwrite, nullable) UIWindow *fw_mainWindow NS_REFINED_FOR_SWIFT;
    
    /// 获取当前主场景
    @property (class, nonatomic, readonly, nullable) UIWindowScene *fw_mainScene API_AVAILABLE(ios(13.0)) NS_REFINED_FOR_SWIFT;
    
    /// 获取最顶部的视图控制器
    @property (nonatomic, readonly, nullable) UIViewController *fw_topViewController NS_REFINED_FOR_SWIFT;
    
    /// 获取最顶部的导航栏控制器。如果顶部VC不含导航栏,返回nil
    @property (nonatomic, readonly, nullable) UINavigationController *fw_topNavigationController NS_REFINED_FOR_SWIFT;
    
    /// 获取最顶部的显示控制器
    @property (nonatomic, readonly, nullable) UIViewController *fw_topPresentedController NS_REFINED_FOR_SWIFT;
    
    /// 使用最顶部的导航栏控制器打开控制器
    - (BOOL)fw_pushViewController:(UIViewController *)viewController animated:(BOOL)animated NS_REFINED_FOR_SWIFT;
    
    /// 使用最顶部的导航栏控制器打开控制器,同时pop指定数量控制器
    - (BOOL)fw_pushViewController:(UIViewController *)viewController pop:(NSUInteger)count animated:(BOOL)animated NS_REFINED_FOR_SWIFT;
    
    /// 使用最顶部的显示控制器弹出控制器,建议present导航栏控制器(可用来push)
    - (void)fw_presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// 使用最顶部的视图控制器打开控制器,自动判断push|present,完成时回调
    - (void)fw_openViewController:(UIViewController *)viewController animated:(BOOL)animated options:(FWNavigatorOptions)options completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// 关闭最顶部的视图控制器,自动判断pop|dismiss,返回是否成功,完成时回调
    - (BOOL)fw_closeViewControllerAnimated:(BOOL)animated options:(FWNavigatorOptions)options completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    @end

UINavigationController+FWNavigator

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UINavigationController (FWNavigator)
    
    #pragma mark - Navigator
    
    /// push新界面,完成时回调
    - (void)fw_pushViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// pop当前界面,完成时回调
    - (nullable UIViewController *)fw_popViewControllerAnimated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// pop到指定界面,完成时回调
    - (nullable NSArray<__kindof UIViewController *> *)fw_popToViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// pop到根界面,完成时回调
    - (nullable NSArray<__kindof UIViewController *> *)fw_popToRootViewControllerAnimated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// 设置界面数组,完成时回调
    - (void)fw_setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// push新界面,同时pop指定数量界面,至少保留一个根控制器,完成时回调
    - (void)fw_pushViewController:(UIViewController *)viewController pop:(NSUInteger)count animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /// pop指定数量界面,0不会pop,至少保留一个根控制器,完成时回调
    - (nullable NSArray<__kindof UIViewController *> *)fw_popViewControllers:(NSUInteger)count animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    #pragma mark - Workflow
    
    /**
     当前最外层工作流名称,即topViewController的工作流名称
     
     @return 工作流名称
     */
    @property (nonatomic, copy, readonly, nullable) NSString *fw_topWorkflowName NS_REFINED_FOR_SWIFT;
    
    /**
     push控制器,并清理最外层工作流(不属于工作流则不清理),完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4、(5、6)、9
     
     @param viewController push的控制器
     @param animated 是否执行动画
     */
    - (void)fw_pushViewController:(UIViewController *)viewController popTopWorkflowAnimated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /**
     push控制器,并清理到指定工作流(不属于工作流则清理),完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、9
     
     @param viewController push的控制器
     @param workflow 指定工作流
     @param animated 是否执行动画
     */
    - (void)fw_pushViewController:(UIViewController *)viewController popToWorkflow:(NSString *)workflow animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /**
     push控制器,并清理非根控制器(只保留根控制器),完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、9
     
     @param viewController push的控制器
     @param animated 是否执行动画
     */
    - (void)fw_pushViewController:(UIViewController *)viewController popToRootWorkflowAnimated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /**
     push控制器,并从外到内清理指定工作流,直到遇到不属于指定工作流的控制器停止,完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4、9
     
     @param viewController push的控制器
     @param workflows 指定工作流
     @param animated 是否执行动画
     */
    - (void)fw_pushViewController:(UIViewController *)viewController popWorkflows:(nullable NSArray<NSString *> *)workflows animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /**
     pop方式清理最外层工作流,至少保留一个根控制器(不属于工作流则不清理),完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4、(5、6)
     
     @param animated 是否执行动画
     */
    - (void)fw_popTopWorkflowAnimated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /**
     pop方式清理到指定工作流,至少保留一个根控制器(不属于工作流则清理),完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)
     
     @param workflow 指定工作流
     @param animated 是否执行动画
     */
    - (void)fw_popToWorkflow:(NSString *)workflow animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    /**
     pop方式从外到内清理指定工作流,直到遇到不属于指定工作流的控制器停止,至少保留一个根控制器,完成时回调
     @note 示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4
     
     @param workflows 指定工作流
     @param animated  是否执行动画
     */
    - (void)fw_popWorkflows:(nullable NSArray<NSString *> *)workflows animated:(BOOL)animated completion:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    @end

CADisplayLink+FWQuartzCore

  • 如果block参数不会被持有并后续执行,可声明为NS_NOESCAPE,不会触发循环引用

    See more

    Declaration

    Objective-C

    @interface CADisplayLink (FWQuartzCore)

CAAnimation+FWQuartzCore

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface CAAnimation (FWQuartzCore)
    
    /// 设置动画开始回调,需要在add之前添加,因为add时会自动拷贝一份对象
    @property (nonatomic, copy, nullable) void (^fw_startBlock)(CAAnimation *animation) NS_REFINED_FOR_SWIFT;
    
    /// 设置动画停止回调
    @property (nonatomic, copy, nullable) void (^fw_stopBlock)(CAAnimation *animation, BOOL finished) NS_REFINED_FOR_SWIFT;
    
    @end

CALayer+FWQuartzCore

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface CALayer (FWQuartzCore)
    
    /// 设置主题背景色,启用主题订阅后可跟随系统改变,清空时需置为nil
    @property (nullable, nonatomic, strong) UIColor *fw_themeBackgroundColor NS_REFINED_FOR_SWIFT;
    
    /// 设置主题边框色,启用主题订阅后可跟随系统改变,清空时需置为nil
    @property (nullable, nonatomic, strong) UIColor *fw_themeBorderColor NS_REFINED_FOR_SWIFT;
    
    /// 设置主题阴影色,启用主题订阅后可跟随系统改变,清空时需置为nil
    @property (nullable, nonatomic, strong) UIColor *fw_themeShadowColor NS_REFINED_FOR_SWIFT;
    
    /// 设置主题内容图片,启用主题订阅后可跟随系统改变,清空时需置为nil
    @property (nullable, nonatomic, strong) UIImage *fw_themeContents NS_REFINED_FOR_SWIFT;
    
    /// 设置阴影颜色、偏移和半径
    - (void)fw_setShadowColor:(nullable UIColor *)color
                      offset:(CGSize)offset
                      radius:(CGFloat)radius NS_REFINED_FOR_SWIFT;
    
    /// 生成图片截图,默认大小为frame.size
    - (nullable UIImage *)fw_snapshotImageWithSize:(CGSize)size NS_REFINED_FOR_SWIFT;
    
    @end

CAGradientLayer+FWQuartzCore

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface CAGradientLayer (FWQuartzCore)
    
    /// 设置主题渐变色,启用主题订阅后可跟随系统改变,清空时需置为nil
    @property (nullable, nonatomic, copy) NSArray<UIColor *> *fw_themeColors NS_REFINED_FOR_SWIFT;
    
    /**
     *  创建渐变层,需手工addLayer
     *
     *  @param frame      渐变区域
     *  @param colors     渐变颜色,CGColor数组,如[黑,白,黑]
     *  @param locations  渐变位置,0~1,如[0.25, 0.5, 0.75]对应颜色为[0-0.25黑,0.25-0.5黑渐变白,0.5-0.75白渐变黑,0.75-1黑]
     *  @param startPoint 渐变开始点,设置渐变方向,左上点为(0,0),右下点为(1,1)
     *  @param endPoint   渐变结束点
     *  @return 渐变Layer
     */
    + (CAGradientLayer *)fw_gradientLayer:(CGRect)frame
                                  colors:(NSArray *)colors
                               locations:(nullable NSArray<NSNumber *> *)locations
                              startPoint:(CGPoint)startPoint
                                endPoint:(CGPoint)endPoint NS_REFINED_FOR_SWIFT;
    
    @end

UIScrollView+FWRefreshPlugin

UIScrollView+FWPullRefresh

UIScrollView+FWInfiniteScroll

UIColor+FWTheme

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIColor (FWTheme)
    
    /// 动态创建主题色,分别指定浅色和深色
    + (UIColor *)fw_themeLight:(UIColor *)light dark:(UIColor *)dark NS_REFINED_FOR_SWIFT;
    
    /// 动态创建主题色,指定提供句柄
    + (UIColor *)fw_themeColor:(UIColor * (^)(FWThemeStyle style))provider NS_REFINED_FOR_SWIFT;
    
    /// 动态创建主题色,指定名称,兼容iOS11+系统方式(仅iOS13+支持动态颜色)和手工指定。失败时返回clear防止崩溃
    + (UIColor *)fw_themeNamed:(NSString *)name NS_REFINED_FOR_SWIFT;
    
    /// 动态创建主题色,指定名称和bundle,兼容iOS11+系统方式(仅iOS13+支持动态颜色)和手工指定。失败时返回clear防止崩溃
    + (UIColor *)fw_themeNamed:(NSString *)name bundle:(nullable NSBundle *)bundle NS_REFINED_FOR_SWIFT;
    
    /// 手工单个注册主题色,未配置主题色或者需兼容iOS11以下时可使用本方式
    + (void)fw_setThemeColor:(nullable UIColor *)color forName:(NSString *)name NS_REFINED_FOR_SWIFT;
    
    /// 手工批量注册主题色,未配置主题色或者需兼容iOS11以下时可使用本方式
    + (void)fw_setThemeColors:(NSDictionary<NSString *, UIColor *> *)nameColors NS_REFINED_FOR_SWIFT;
    
    /// 获取当前主题样式对应静态颜色,主要用于iOS13以下兼容主题切换
    @property (nonatomic, readonly) UIColor *fw_color NS_SWIFT_NAME(__fw_color) NS_REFINED_FOR_SWIFT;
    
    /// 指定主题样式获取对应静态颜色,iOS13+可跟随系统改变
    - (UIColor *)fw_colorForStyle:(FWThemeStyle)style NS_REFINED_FOR_SWIFT;
    
    /// 是否是主题颜色,仅支持判断使用fwTheme创建的颜色
    @property (nonatomic, assign, readonly) BOOL fw_isThemeColor NS_REFINED_FOR_SWIFT;
    
    @end

UIImage+FWTheme

  • UIImage主题分类

    Note

    注意UIImage默认只有name方式且配置了any和dark才支持动态切换,否则只能重新赋值才会变化。 为避免内存泄漏,通过fwTheme方式创建的主题图片不能直接用于显示,显示时请调用fwImage方法
    See more

    Declaration

    Objective-C

    @interface UIImage (FWTheme)

UIImageAsset+FWTheme

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImageAsset (FWTheme)
    
    /// 创建主题动态图片资源,分别指定浅色和深色,系统方式,推荐使用
    + (UIImageAsset *)fw_themeLight:(nullable UIImage *)light dark:(nullable UIImage *)dark NS_REFINED_FOR_SWIFT;
    
    /// 创建主题动态图片资源,指定提供句柄,内部使用FWThemeObject实现
    + (UIImageAsset *)fw_themeAsset:(UIImage * _Nullable (^)(FWThemeStyle style))provider NS_REFINED_FOR_SWIFT;
    
    /// 获取当前主题样式对应静态图片用于显示,iOS13+可跟随系统改变
    @property (nullable, nonatomic, readonly) UIImage *fw_image NS_REFINED_FOR_SWIFT;
    
    /// 指定主题样式获取对应静态图片用于显示,iOS13+可跟随系统改变
    - (nullable UIImage *)fw_imageForStyle:(FWThemeStyle)style NS_REFINED_FOR_SWIFT;
    
    /// 是否是主题图片资源,仅支持判断使用fwTheme创建的图片资源
    @property (nonatomic, assign, readonly) BOOL fw_isThemeAsset NS_REFINED_FOR_SWIFT;
    
    @end

NSObject+FWTheme

FWToastPlugin

  • UIWindow全局使用吐司插件,内部使用UIWindow.fw.mainWindow

    See more

    Declaration

    Objective-C

    @interface UIWindow (FWToastPlugin)

UIApplication+FWToolkit

  • 注意Info.plist文件URL SCHEME配置项只影响canOpenUrl方法,不影响openUrl。微信返回app就是获取sourceUrl,直接openUrl实现。因为跳转微信的时候,来源app肯定已打开过,可以跳转,只要不检查canOpenUrl,就可以跳转回app

    See more

    Declaration

    Objective-C

    @interface UIApplication (FWToolkit)

UIColor+FWToolkit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIColor (FWToolkit)
    
    /// 获取当前颜色指定透明度的新颜色
    - (UIColor *)fw_colorWithAlpha:(CGFloat)alpha NS_REFINED_FOR_SWIFT;
    
    /// 读取颜色的十六进制值RGB,不含透明度
    @property (nonatomic, assign, readonly) long fw_hexValue NS_REFINED_FOR_SWIFT;
    
    /// 读取颜色的透明度值,范围0~1
    @property (nonatomic, assign, readonly) CGFloat fw_alphaValue NS_REFINED_FOR_SWIFT;
    
    /// 读取颜色的十六进制字符串RGB,不含透明度
    @property (nonatomic, copy, readonly) NSString *fw_hexString NS_REFINED_FOR_SWIFT;
    
    /// 读取颜色的十六进制字符串RGBA|ARGB(透明度为1时RGB),包含透明度
    @property (nonatomic, copy, readonly) NSString *fw_hexAlphaString NS_REFINED_FOR_SWIFT;
    
    /// 设置十六进制颜色标准为ARGB|RGBA,启用为ARGB,默认为RGBA
    @property (class, nonatomic, assign) BOOL fw_colorStandardARGB NS_REFINED_FOR_SWIFT;
    
    /// 获取透明度为1.0的RGB随机颜色
    @property (class, nonatomic, readonly) UIColor *fw_randomColor NS_REFINED_FOR_SWIFT;
    
    /// 从十六进制值初始化,格式:0x20B2AA,透明度为1.0
    + (UIColor *)fw_colorWithHex:(long)hex NS_REFINED_FOR_SWIFT;
    
    /// 从十六进制值初始化,格式:0x20B2AA,自定义透明度
    + (UIColor *)fw_colorWithHex:(long)hex alpha:(CGFloat)alpha NS_REFINED_FOR_SWIFT;
    
    /// 从十六进制字符串初始化,支持RGB、RGBA|ARGB,格式:@"20B2AA", @"#FFFFFF",透明度为1.0,失败时返回clear
    + (UIColor *)fw_colorWithHexString:(NSString *)hexString NS_REFINED_FOR_SWIFT;
    
    /// 从十六进制字符串初始化,支持RGB、RGBA|ARGB,格式:@"20B2AA", @"#FFFFFF",自定义透明度,失败时返回clear
    + (UIColor *)fw_colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha NS_REFINED_FOR_SWIFT;
    
    /// 以指定模式添加混合颜色
    - (UIColor *)fw_addColor:(UIColor *)color blendMode:(CGBlendMode)blendMode NS_REFINED_FOR_SWIFT;
    
    /// 当前颜色修改亮度比率的颜色
    - (UIColor *)fw_brightnessColor:(CGFloat)ratio NS_REFINED_FOR_SWIFT;
    
    /// 判断当前颜色是否为深色
    @property (nonatomic, assign, readonly) BOOL fw_isDarkColor NS_REFINED_FOR_SWIFT;
    
    /**
     创建渐变颜色,支持四个方向,默认向下Down
     
     @param size 渐变尺寸,非渐变边可以设置为1。如CGSizeMake(1, 50)
     @param colors 渐变颜色,CGColor数组,如:@[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor blueColor].CGColor]
     @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0};
     @param direction 渐变方向,自动计算startPoint和endPoint,支持四个方向,默认向下Down
     @return 渐变色
     */
    + (UIColor *)fw_gradientColorWithSize:(CGSize)size
                                  colors:(NSArray *)colors
                               locations:(nullable const CGFloat *)locations
                               direction:(UISwipeGestureRecognizerDirection)direction NS_REFINED_FOR_SWIFT;
    
    /**
     创建渐变颜色
     
     @param size 渐变尺寸,非渐变边可以设置为1。如CGSizeMake(1, 50)
     @param colors 渐变颜色,CGColor数组,如:@[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor blueColor].CGColor]
     @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0};
     @param startPoint 渐变开始点,需要根据rect计算
     @param endPoint 渐变结束点,需要根据rect计算
     @return 渐变色
     */
    + (UIColor *)fw_gradientColorWithSize:(CGSize)size
                                  colors:(NSArray *)colors
                               locations:(nullable const CGFloat *)locations
                              startPoint:(CGPoint)startPoint
                                endPoint:(CGPoint)endPoint NS_REFINED_FOR_SWIFT;
    
    @end

UIFont+FWToolkit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIFont (FWToolkit)
    
    /// 全局自定义字体句柄,优先调用
    @property (class, nonatomic, copy, nullable) UIFont * (^fw_fontBlock)(CGFloat size, UIFontWeight weight) NS_REFINED_FOR_SWIFT;
    
    /// 是否自动等比例缩放字体,默认NO。启用后所有fw字体size都会自动*relativeScale
    @property (class, nonatomic, assign) BOOL fw_autoScale NS_REFINED_FOR_SWIFT;
    
    /// 返回系统Thin字体
    + (UIFont *)fw_thinFontOfSize:(CGFloat)size NS_REFINED_FOR_SWIFT;
    /// 返回系统Light字体
    + (UIFont *)fw_lightFontOfSize:(CGFloat)size NS_REFINED_FOR_SWIFT;
    /// 返回系统Regular字体
    + (UIFont *)fw_fontOfSize:(CGFloat)size NS_REFINED_FOR_SWIFT;
    /// 返回系统Medium字体
    + (UIFont *)fw_mediumFontOfSize:(CGFloat)size NS_REFINED_FOR_SWIFT;
    /// 返回系统Semibold字体
    + (UIFont *)fw_semiboldFontOfSize:(CGFloat)size NS_REFINED_FOR_SWIFT;
    /// 返回系统Bold字体
    + (UIFont *)fw_boldFontOfSize:(CGFloat)size NS_REFINED_FOR_SWIFT;
    
    /// 创建指定尺寸和weight的系统字体
    + (UIFont *)fw_fontOfSize:(CGFloat)size weight:(UIFontWeight)weight NS_REFINED_FOR_SWIFT;
    
    /// 是否是粗体
    @property (nonatomic, assign, readonly) BOOL fw_isBold NS_REFINED_FOR_SWIFT;
    
    /// 是否是斜体
    @property (nonatomic, assign, readonly) BOOL fw_isItalic NS_REFINED_FOR_SWIFT;
    
    /// 当前字体的粗体字体
    @property (nonatomic, strong, readonly) UIFont *fw_boldFont NS_REFINED_FOR_SWIFT;
    
    /// 当前字体的非粗体字体
    @property (nonatomic, strong, readonly) UIFont *fw_nonBoldFont NS_REFINED_FOR_SWIFT;
    
    /// 当前字体的斜体字体
    @property (nonatomic, strong, readonly) UIFont *fw_italicFont NS_REFINED_FOR_SWIFT;
    
    /// 当前字体的非斜体字体
    @property (nonatomic, strong, readonly) UIFont *fw_nonItalicFont NS_REFINED_FOR_SWIFT;
    
    /// 字体空白高度(上下之和)
    @property (nonatomic, assign, readonly) CGFloat fw_spaceHeight NS_REFINED_FOR_SWIFT;
    
    /// 根据字体计算指定倍数行间距的实际行距值(减去空白高度),示例:行间距为0.5倍实际高度
    - (CGFloat)fw_lineSpacingWithMultiplier:(CGFloat)multiplier NS_REFINED_FOR_SWIFT;
    
    /// 根据字体计算指定倍数行高的实际行高值(减去空白高度),示例:行高为1.5倍实际高度
    - (CGFloat)fw_lineHeightWithMultiplier:(CGFloat)multiplier NS_REFINED_FOR_SWIFT;
    
    /// 计算当前字体与指定字体居中对齐的偏移值
    - (CGFloat)fw_baselineOffset:(UIFont *)font NS_REFINED_FOR_SWIFT;
    
    @end

UIImage+FWToolkit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImage (FWToolkit)
    
    /// 从当前图片创建指定透明度的图片
    - (nullable UIImage *)fw_imageWithAlpha:(CGFloat)alpha NS_REFINED_FOR_SWIFT;
    
    /// 从当前图片混合颜色创建UIImage,默认kCGBlendModeDestinationIn模式,适合透明图标
    - (nullable UIImage *)fw_imageWithTintColor:(UIColor *)tintColor NS_REFINED_FOR_SWIFT;
    
    /// 从当前UIImage混合颜色创建UIImage,自定义模式
    - (nullable UIImage *)fw_imageWithTintColor:(UIColor *)tintColor blendMode:(CGBlendMode)blendMode NS_REFINED_FOR_SWIFT;
    
    /// 缩放图片到指定大小
    - (nullable UIImage *)fw_imageWithScaleSize:(CGSize)size NS_REFINED_FOR_SWIFT;
    
    /// 缩放图片到指定大小,指定模式
    - (nullable UIImage *)fw_imageWithScaleSize:(CGSize)size contentMode:(UIViewContentMode)contentMode NS_REFINED_FOR_SWIFT;
    
    /// 按指定模式绘制图片
    - (void)fw_drawInRect:(CGRect)rect withContentMode:(UIViewContentMode)contentMode clipsToBounds:(BOOL)clipsToBounds NS_REFINED_FOR_SWIFT;
    
    /// 裁剪指定区域图片
    - (nullable UIImage *)fw_imageWithCropRect:(CGRect)rect NS_REFINED_FOR_SWIFT;
    
    /// 指定颜色填充图片边缘
    - (nullable UIImage *)fw_imageWithInsets:(UIEdgeInsets)insets color:(nullable UIColor *)color NS_REFINED_FOR_SWIFT;
    
    /// 拉伸图片(平铺模式),指定端盖区域(不拉伸区域)
    - (UIImage *)fw_imageWithCapInsets:(UIEdgeInsets)insets NS_REFINED_FOR_SWIFT;
    
    /// 拉伸图片(指定模式),指定端盖区域(不拉伸区域)。Tile为平铺模式,Stretch为拉伸模式
    - (UIImage *)fw_imageWithCapInsets:(UIEdgeInsets)insets resizingMode:(UIImageResizingMode)resizingMode NS_REFINED_FOR_SWIFT;
    
    /// 生成圆角图片
    - (nullable UIImage *)fw_imageWithCornerRadius:(CGFloat)radius NS_REFINED_FOR_SWIFT;
    
    /// 按角度常数(0~360)转动图片,默认图片尺寸适应内容
    - (nullable UIImage *)fw_imageWithRotateDegree:(CGFloat)degree NS_REFINED_FOR_SWIFT;
    
    /// 按角度常数(0~360)转动图片,指定图片尺寸是否延伸来适应内容,否则图片尺寸不变,内容被裁剪
    - (nullable UIImage *)fw_imageWithRotateDegree:(CGFloat)degree fitSize:(BOOL)fitSize NS_REFINED_FOR_SWIFT;
    
    /// 生成mark图片
    - (nullable UIImage *)fw_imageWithMaskImage:(UIImage *)maskImage NS_REFINED_FOR_SWIFT;
    
    /// 图片合并,并制定叠加图片的起始位置
    - (nullable UIImage *)fw_imageWithMergeImage:(UIImage *)image atPoint:(CGPoint)point NS_REFINED_FOR_SWIFT;
    
    /// 图片应用CIFilter滤镜处理
    - (nullable UIImage *)fw_imageWithFilter:(CIFilter *)filter NS_REFINED_FOR_SWIFT;
    
    /// 压缩图片到指定字节,图片太大时会改为JPG格式。不保证图片大小一定小于该大小
    - (nullable UIImage *)fw_compressImageWithMaxLength:(NSInteger)maxLength NS_REFINED_FOR_SWIFT;
    
    /// 压缩图片到指定字节,图片太大时会改为JPG格式,可设置递减压缩率,默认0.1。不保证图片大小一定小于该大小
    - (nullable NSData *)fw_compressDataWithMaxLength:(NSInteger)maxLength compressRatio:(CGFloat)compressRatio NS_REFINED_FOR_SWIFT;
    
    /// 长边压缩图片尺寸,获取等比例的图片
    - (nullable UIImage *)fw_compressImageWithMaxWidth:(NSInteger)maxWidth NS_REFINED_FOR_SWIFT;
    
    /// 通过指定图片最长边,获取等比例的图片size
    - (CGSize)fw_scaleSizeWithMaxWidth:(CGFloat)maxWidth NS_REFINED_FOR_SWIFT;
    
    /// 获取原始渲染模式图片,始终显示原色,不显示tintColor。默认自动根据上下文
    @property (nonatomic, readonly) UIImage *fw_originalImage NS_REFINED_FOR_SWIFT;
    
    /// 获取模板渲染模式图片,始终显示tintColor,不显示原色。默认自动根据上下文
    @property (nonatomic, readonly) UIImage *fw_templateImage NS_REFINED_FOR_SWIFT;
    
    /// 判断图片是否有透明通道
    @property (nonatomic, assign, readonly) BOOL fw_hasAlpha NS_REFINED_FOR_SWIFT;
    
    /// 获取当前图片的像素大小,多倍图会放大到一倍
    @property (nonatomic, assign, readonly) CGSize fw_pixelSize NS_REFINED_FOR_SWIFT;
    
    /// 从视图创建UIImage,生成截图,主线程调用
    + (nullable UIImage *)fw_imageWithView:(UIView *)view NS_REFINED_FOR_SWIFT;
    
    /// 从颜色创建UIImage,默认尺寸1x1
    + (nullable UIImage *)fw_imageWithColor:(UIColor *)color NS_REFINED_FOR_SWIFT;
    
    /// 从颜色创建UIImage,指定尺寸
    + (nullable UIImage *)fw_imageWithColor:(UIColor *)color size:(CGSize)size NS_REFINED_FOR_SWIFT;
    
    /// 从颜色创建UIImage,指定尺寸和圆角
    + (nullable UIImage *)fw_imageWithColor:(UIColor *)color size:(CGSize)size cornerRadius:(CGFloat)radius NS_REFINED_FOR_SWIFT;
    
    /// 从block创建UIImage,指定尺寸
    + (nullable UIImage *)fw_imageWithSize:(CGSize)size block:(void (NS_NOESCAPE ^)(CGContextRef context))block NS_REFINED_FOR_SWIFT;
    
    /// 保存图片到相册,保存成功时error为nil
    - (void)fw_saveImageWithCompletion:(nullable void (^)(NSError * _Nullable error))completion NS_SWIFT_NAME(__fw_saveImage(completion:)) NS_REFINED_FOR_SWIFT;
    
    /// 保存视频到相册,保存成功时error为nil。如果视频地址为NSURL,需使用NSURL.path
    + (void)fw_saveVideo:(NSString *)videoPath withCompletion:(nullable void (^)(NSError * _Nullable error))completion NS_REFINED_FOR_SWIFT;
    
    /// 获取灰度图
    @property (nonatomic, readonly, nullable) UIImage *fw_grayImage NS_REFINED_FOR_SWIFT;
    
    /// 获取图片的平均颜色
    @property (nonatomic, readonly) UIColor *fw_averageColor NS_REFINED_FOR_SWIFT;
    
    /// 倒影图片
    - (nullable UIImage *)fw_imageWithReflectScale:(CGFloat)scale NS_REFINED_FOR_SWIFT;
    
    /// 倒影图片
    - (nullable UIImage *)fw_imageWithReflectScale:(CGFloat)scale gap:(CGFloat)gap alpha:(CGFloat)alpha NS_REFINED_FOR_SWIFT;
    
    /// 阴影图片
    - (nullable UIImage *)fw_imageWithShadowColor:(UIColor *)color offset:(CGSize)offset blur:(CGFloat)blur NS_REFINED_FOR_SWIFT;
    
    /// 获取装饰图片
    @property (nonatomic, readonly) UIImage *fw_maskImage NS_REFINED_FOR_SWIFT;
    
    /// 高斯模糊图片,默认模糊半径为10,饱和度为1。注意CGContextDrawImage如果图片尺寸太大会导致内存不足闪退,建议先压缩再调用
    - (nullable UIImage *)fw_imageWithBlurRadius:(CGFloat)blurRadius saturationDelta:(CGFloat)saturationDelta tintColor:(nullable UIColor *)tintColor maskImage:(nullable UIImage *)maskImage NS_REFINED_FOR_SWIFT;
    
    /// 如果没有透明通道,增加透明通道
    @property (nonatomic, readonly) UIImage *fw_alphaImage NS_REFINED_FOR_SWIFT;
    
    /// 截取View所有视图,包括旋转缩放效果
    + (nullable UIImage *)fw_imageWithView:(UIView *)view limitWidth:(CGFloat)limitWidth NS_REFINED_FOR_SWIFT;
    
    /// 获取AppIcon图片
    + (nullable UIImage *)fw_appIconImage NS_REFINED_FOR_SWIFT;
    
    /// 获取AppIcon指定尺寸图片,名称格式:AppIcon60x60
    + (nullable UIImage *)fw_appIconImage:(CGSize)size NS_REFINED_FOR_SWIFT;
    
    /// 从Pdf数据或者路径创建UIImage
    + (nullable UIImage *)fw_imageWithPdf:(id)path NS_REFINED_FOR_SWIFT;
    
    /// 从Pdf数据或者路径创建指定大小UIImage
    + (nullable UIImage *)fw_imageWithPdf:(id)path size:(CGSize)size NS_REFINED_FOR_SWIFT;
    
    /**
     创建渐变颜色UIImage,支持四个方向,默认向下Down
     
     @param size 图片大小
     @param colors 渐变颜色,CGColor数组,如:@[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor blueColor].CGColor]
     @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0};
     @param direction 渐变方向,自动计算startPoint和endPoint,支持四个方向,默认向下Down
     @return 渐变颜色UIImage
     */
    + (nullable UIImage *)fw_gradientImageWithSize:(CGSize)size
                                           colors:(NSArray *)colors
                                        locations:(nullable const CGFloat *)locations
                                        direction:(UISwipeGestureRecognizerDirection)direction NS_REFINED_FOR_SWIFT;
    
    /**
     创建渐变颜色UIImage
     
     @param size 图片大小
     @param colors 渐变颜色,CGColor数组,如:@[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor blueColor].CGColor]
     @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0};
     @param startPoint 渐变开始点,需要根据rect计算
     @param endPoint 渐变结束点,需要根据rect计算
     @return 渐变颜色UIImage
     */
    + (nullable UIImage *)fw_gradientImageWithSize:(CGSize)size
                                           colors:(NSArray *)colors
                                        locations:(nullable const CGFloat *)locations
                                       startPoint:(CGPoint)startPoint
                                         endPoint:(CGPoint)endPoint NS_REFINED_FOR_SWIFT;
    
    @end

UINavigationController+FWToolkit

  • 当自定义left按钮或隐藏导航栏之后,系统返回手势默认失效,可调用此方法全局开启返回代理。开启后自动将开关代理给顶部VC的shouldPopController、popGestureEnabled属性控制。interactivePop手势禁用时不生效

    See more

    Declaration

    Objective-C

    @interface UINavigationController (FWToolkit)

UIBezierPath+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIBezierPath (FWUIKit)
    
    /// 绘制形状图片,自定义画笔宽度、画笔颜色、填充颜色,填充颜色为nil时不执行填充
    - (nullable UIImage *)fw_shapeImage:(CGSize)size
                         strokeWidth:(CGFloat)strokeWidth
                         strokeColor:(UIColor *)strokeColor
                           fillColor:(nullable UIColor *)fillColor NS_REFINED_FOR_SWIFT;
    
    /// 绘制形状Layer,自定义画笔宽度、画笔颜色、填充颜色,填充颜色为nil时不执行填充
    - (CAShapeLayer *)fw_shapeLayer:(CGRect)rect
                     strokeWidth:(CGFloat)strokeWidth
                     strokeColor:(UIColor *)strokeColor
                       fillColor:(nullable UIColor *)fillColor NS_REFINED_FOR_SWIFT;
    
    /// 根据点计算折线路径(NSValue点)
    + (UIBezierPath *)fw_linesWithPoints:(NSArray *)points NS_REFINED_FOR_SWIFT;
    
    /// 根据点计算贝塞尔曲线路径
    + (UIBezierPath *)fw_quadCurvedPathWithPoints:(NSArray *)points NS_REFINED_FOR_SWIFT;
    
    /// 计算两点的中心点
    + (CGPoint)fw_middlePoint:(CGPoint)p1 withPoint:(CGPoint)p2 NS_REFINED_FOR_SWIFT;
    
    /// 计算两点的贝塞尔曲线控制点
    + (CGPoint)fw_controlPoint:(CGPoint)p1 withPoint:(CGPoint)p2 NS_REFINED_FOR_SWIFT;
    
    /// 将角度(0~360)转换为弧度,周长为2*M_PI*r
    + (CGFloat)fw_radianWithDegree:(CGFloat)degree NS_REFINED_FOR_SWIFT;
    
    /// 将弧度转换为角度(0~360)
    + (CGFloat)fw_degreeWithRadian:(CGFloat)radian NS_REFINED_FOR_SWIFT;
    
    /// 根据滑动方向计算rect的线段起点、终点中心点坐标数组(示范:田)。默认从上到下滑动
    + (NSArray<NSValue *> *)fw_linePointsWithRect:(CGRect)rect direction:(UISwipeGestureRecognizerDirection)direction NS_REFINED_FOR_SWIFT;
    
    @end

UIImageView+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIImageView (FWUIKit)
    
    /// 设置图片模式为ScaleAspectFill,自动拉伸不变形,超过区域隐藏。可通过appearance统一设置
    - (void)fw_setContentModeAspectFill UI_APPEARANCE_SELECTOR NS_REFINED_FOR_SWIFT;
    
    /// 优化图片人脸显示,参考:https://github.com/croath/UIImageView-BetterFace
    - (void)fw_faceAware NS_REFINED_FOR_SWIFT;
    
    /// 倒影效果
    - (void)fw_reflect NS_REFINED_FOR_SWIFT;
    
    /// 图片水印
    - (void)fw_setImage:(UIImage *)image watermarkImage:(UIImage *)watermarkImage inRect:(CGRect)rect NS_REFINED_FOR_SWIFT;
    
    /// 文字水印,指定区域
    - (void)fw_setImage:(UIImage *)image watermarkString:(NSAttributedString *)watermarkString inRect:(CGRect)rect NS_REFINED_FOR_SWIFT;
    
    /// 文字水印,指定坐标
    - (void)fw_setImage:(UIImage *)image watermarkString:(NSAttributedString *)watermarkString atPoint:(CGPoint)point NS_REFINED_FOR_SWIFT;
    
    @end

UIWindow+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIWindow (FWUIKit)
    
    /// 选中并获取指定索引TabBar根视图控制器,适用于Tabbar包含多个Navigation结构,找不到返回nil
    - (nullable __kindof UIViewController *)fw_selectTabBarIndex:(NSUInteger)index NS_REFINED_FOR_SWIFT;
    
    /// 选中并获取指定类TabBar根视图控制器,适用于Tabbar包含多个Navigation结构,找不到返回nil
    - (nullable __kindof UIViewController *)fw_selectTabBarController:(Class)viewController NS_REFINED_FOR_SWIFT;
    
    /// 选中并获取指定条件TabBar根视图控制器,适用于Tabbar包含多个Navigation结构,找不到返回nil
    - (nullable __kindof UIViewController *)fw_selectTabBarBlock:(BOOL (NS_NOESCAPE ^)(__kindof UIViewController *viewController))block NS_REFINED_FOR_SWIFT;
    
    @end

UILabel+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UILabel (FWUIKit)
    
    /// 快速设置attributedText样式,设置后调用setText:会自动转发到setAttributedText:方法
    @property (nonatomic, copy, nullable) NSDictionary<NSAttributedStringKey, id> *fw_textAttributes NS_REFINED_FOR_SWIFT;
    
    /// 快速设置文字的行高,优先级低于fwTextAttributes,设置后调用setText:会自动转发到setAttributedText:方法。小于0时恢复默认行高
    @property (nonatomic, assign) CGFloat fw_lineHeight NS_REFINED_FOR_SWIFT;
    
    /// 自定义内容边距,未设置时为系统默认。当内容为空时不参与intrinsicContentSize和sizeThatFits:计算,方便自动布局
    @property (nonatomic, assign) UIEdgeInsets fw_contentInset NS_REFINED_FOR_SWIFT;
    
    /// 纵向分布方式,默认居中
    @property (nonatomic, assign) UIControlContentVerticalAlignment fw_verticalAlignment NS_REFINED_FOR_SWIFT;
    
    /// 添加点击手势并自动识别NSLinkAttributeName|URL属性,点击高亮时回调链接,点击其它区域回调nil
    - (void)fw_addLinkGestureWithBlock:(void (^)(id _Nullable link))block NS_REFINED_FOR_SWIFT;
    
    /// 获取手势触发位置的文本属性,可实现行内点击效果等,allowsSpacing默认为NO空白处不可点击。为了识别更准确,attributedText需指定font
    - (NSDictionary<NSAttributedStringKey, id> *)fw_attributesWithGesture:(UIGestureRecognizer *)gesture allowsSpacing:(BOOL)allowsSpacing NS_REFINED_FOR_SWIFT;
    
    /// 快速设置标签
    - (void)fw_setFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor NS_REFINED_FOR_SWIFT;
    
    /// 快速设置标签并指定文本
    - (void)fw_setFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor text:(nullable NSString *)text NS_REFINED_FOR_SWIFT;
    
    /// 快速创建标签
    + (instancetype)fw_labelWithFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor NS_REFINED_FOR_SWIFT;
    
    /// 快速创建标签并指定文本
    + (instancetype)fw_labelWithFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor text:(nullable NSString *)text NS_REFINED_FOR_SWIFT;
    
    /// 计算当前文本所占尺寸,需frame或者宽度布局完整
    @property (nonatomic, assign, readonly) CGSize fw_textSize NS_REFINED_FOR_SWIFT;
    
    /// 计算当前属性文本所占尺寸,需frame或者宽度布局完整,attributedText需指定字体
    @property (nonatomic, assign, readonly) CGSize fw_attributedTextSize NS_REFINED_FOR_SWIFT;
    
    @end

UIControl+FWUIKit

  • 防重复点击可以手工控制enabled或userInteractionEnabled,如request开始时禁用,结束时启用等

    See more

    Declaration

    Objective-C

    @interface UIControl (FWUIKit)

UIButton+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIButton (FWUIKit)
    
    /// 自定义按钮禁用时的alpha,如0.5,默认0不生效
    @property (nonatomic, assign) CGFloat fw_disabledAlpha NS_REFINED_FOR_SWIFT;
    
    /// 自定义按钮高亮时的alpha,如0.5,默认0不生效
    @property (nonatomic, assign) CGFloat fw_highlightedAlpha NS_REFINED_FOR_SWIFT;
    
    /// 快速设置文本按钮
    - (void)fw_setTitle:(nullable NSString *)title font:(nullable UIFont *)font titleColor:(nullable UIColor *)titleColor NS_REFINED_FOR_SWIFT;
    
    /// 快速设置文本
    - (void)fw_setTitle:(nullable NSString *)title NS_REFINED_FOR_SWIFT;
    
    /// 快速设置图片
    - (void)fw_setImage:(nullable UIImage *)image NS_REFINED_FOR_SWIFT;
    
    /// 设置图片的居中边位置,需要在setImage和setTitle之后调用才生效,且button大小大于图片+文字+间距
    ///
    /// imageEdgeInsets: 仅有image时相对于button,都有时上左下相对于button,右相对于title
    /// titleEdgeInsets: 仅有title时相对于button,都有时上右下相对于button,左相对于image
    - (void)fw_setImageEdge:(UIRectEdge)edge spacing:(CGFloat)spacing NS_REFINED_FOR_SWIFT;
    
    /// 设置状态背景色
    - (void)fw_setBackgroundColor:(nullable UIColor *)backgroundColor forState:(UIControlState)state NS_REFINED_FOR_SWIFT;
    
    /// 快速创建文本按钮
    + (instancetype)fw_buttonWithTitle:(nullable NSString *)title font:(nullable UIFont *)font titleColor:(nullable UIColor *)titleColor NS_REFINED_FOR_SWIFT;
    
    /// 快速创建图片按钮
    + (instancetype)fw_buttonWithImage:(nullable UIImage *)image NS_REFINED_FOR_SWIFT;
    
    /// 开始按钮倒计时,从window移除时自动取消。等待时按钮disabled,非等待时enabled。时间支持格式化,示例:重新获取(%lds)
    - (dispatch_source_t)fw_startCountDown:(NSInteger)seconds title:(NSString *)title waitTitle:(NSString *)waitTitle NS_REFINED_FOR_SWIFT;
    
    @end

UIScrollView+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIScrollView (FWUIKit)
    
    /// 判断当前scrollView内容是否足够滚动
    @property (nonatomic, assign, readonly) BOOL fw_canScroll NS_REFINED_FOR_SWIFT;
    
    /// 判断当前的scrollView内容是否足够水平滚动
    @property (nonatomic, assign, readonly) BOOL fw_canScrollHorizontal NS_REFINED_FOR_SWIFT;
    
    /// 判断当前的scrollView内容是否足够纵向滚动
    @property (nonatomic, assign, readonly) BOOL fw_canScrollVertical NS_REFINED_FOR_SWIFT;
    
    /// 当前scrollView滚动到指定边
    - (void)fw_scrollToEdge:(UIRectEdge)edge animated:(BOOL)animated NS_REFINED_FOR_SWIFT;
    
    /// 是否已滚动到指定边
    - (BOOL)fw_isScrollToEdge:(UIRectEdge)edge NS_REFINED_FOR_SWIFT;
    
    /// 获取当前的scrollView滚动到指定边时的contentOffset(包含contentInset)
    - (CGPoint)fw_contentOffsetOfEdge:(UIRectEdge)edge NS_REFINED_FOR_SWIFT;
    
    /// 总页数,自动识别翻页方向
    @property (nonatomic, assign, readonly) NSInteger fw_totalPage NS_REFINED_FOR_SWIFT;
    
    /// 当前页数,不支持动画,自动识别翻页方向
    @property (nonatomic, assign) NSInteger fw_currentPage NS_REFINED_FOR_SWIFT;
    
    /// 设置当前页数,支持动画,自动识别翻页方向
    - (void)fw_setCurrentPage:(NSInteger)page animated:(BOOL)animated NS_REFINED_FOR_SWIFT;
    
    /// 是否是最后一页,自动识别翻页方向
    @property (nonatomic, assign, readonly) BOOL fw_isLastPage NS_REFINED_FOR_SWIFT;
    
    /// 快捷设置contentOffset.x
    @property (nonatomic, assign) CGFloat fw_contentOffsetX NS_REFINED_FOR_SWIFT;
    
    /// 快捷设置contentOffset.y
    @property (nonatomic, assign) CGFloat fw_contentOffsetY NS_REFINED_FOR_SWIFT;
    
    /// 内容视图,子视图需添加到本视图,布局约束完整时可自动滚动
    @property (nonatomic, strong, readonly) UIView *fw_contentView NS_REFINED_FOR_SWIFT;
    
    /**
     设置自动布局视图悬停到指定父视图固定位置,在scrollViewDidScroll:中调用即可
     
     @param view 需要悬停的视图,须占满fromSuperview
     @param fromSuperview 起始的父视图,须是scrollView的子视图
     @param toSuperview 悬停的目标视图,须是scrollView的父级视图,一般控制器self.view
     @param toPosition 需要悬停的目标位置,相对于toSuperview的originY位置
     @return 相对于悬浮位置的距离,可用来设置导航栏透明度等
     */
    - (CGFloat)fw_hoverView:(UIView *)view
             fromSuperview:(UIView *)fromSuperview
               toSuperview:(UIView *)toSuperview
                toPosition:(CGFloat)toPosition NS_REFINED_FOR_SWIFT;
    
    /// 是否开始识别pan手势
    @property (nullable, nonatomic, copy) BOOL (^fw_shouldBegin)(UIGestureRecognizer *gestureRecognizer) NS_REFINED_FOR_SWIFT;
    
    /// 是否允许同时识别多个手势
    @property (nullable, nonatomic, copy) BOOL (^fw_shouldRecognizeSimultaneously)(UIGestureRecognizer *gestureRecognizer, UIGestureRecognizer *otherGestureRecognizer) NS_REFINED_FOR_SWIFT;
    
    /// 是否另一个手势识别失败后,才能识别pan手势
    @property (nullable, nonatomic, copy) BOOL (^fw_shouldRequireFailure)(UIGestureRecognizer *gestureRecognizer, UIGestureRecognizer *otherGestureRecognizer) NS_REFINED_FOR_SWIFT;
    
    /// 是否pan手势识别失败后,才能识别另一个手势
    @property (nullable, nonatomic, copy) BOOL (^fw_shouldBeRequiredToFail)(UIGestureRecognizer *gestureRecognizer, UIGestureRecognizer *otherGestureRecognizer) NS_REFINED_FOR_SWIFT;
    
    @end

UIGestureRecognizer+FWUIKit

  • gestureRecognizerShouldBegin:是否继续进行手势识别,默认YES shouldRecognizeSimultaneouslyWithGestureRecognizer: 是否支持多手势触发。默认NO shouldRequireFailureOfGestureRecognizer:是否otherGestureRecognizer触发失败时,才开始触发gestureRecognizer。返回YES,第一个手势失败 shouldBeRequiredToFailByGestureRecognizer:在otherGestureRecognizer识别其手势之前,是否gestureRecognizer必须触发失败。返回YES,第二个手势失败

    See more

    Declaration

    Objective-C

    @interface UIGestureRecognizer (FWUIKit)

UIPanGestureRecognizer+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIPanGestureRecognizer (FWUIKit)
    
    /// 当前滑动方向,如果多个方向滑动,取绝对值较大的一方,失败返回0
    @property (nonatomic, assign, readonly) UISwipeGestureRecognizerDirection fw_swipeDirection NS_REFINED_FOR_SWIFT;
    
    /// 当前滑动进度,滑动绝对值相对于手势视图的宽或高
    @property (nonatomic, assign, readonly) CGFloat fw_swipePercent NS_REFINED_FOR_SWIFT;
    
    /// 计算指定方向的滑动进度
    - (CGFloat)fw_swipePercentOfDirection:(UISwipeGestureRecognizerDirection)direction NS_REFINED_FOR_SWIFT;
    
    @end

UIPageControl+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIPageControl (FWUIKit)
    
    /// 自定义圆点大小,默认{10, 10}
    @property (nonatomic, assign) CGSize fw_preferredSize NS_REFINED_FOR_SWIFT;
    
    @end

UISlider+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UISlider (FWUIKit)
    
    /// 中间圆球的大小,默认zero
    @property (nonatomic, assign) CGSize fw_thumbSize NS_REFINED_FOR_SWIFT;
    
    /// 中间圆球的颜色,默认nil
    @property (nonatomic, strong, nullable) UIColor *fw_thumbColor NS_REFINED_FOR_SWIFT;
    
    @end

UISwitch+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UISwitch (FWUIKit)
    
    /// 自定义尺寸大小,默认{51,31}
    @property (nonatomic, assign) CGSize fw_preferredSize NS_REFINED_FOR_SWIFT;
    
    @end

UITextField+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UITextField (FWUIKit)
    
    /// 最大字数限制,0为无限制,二选一
    @property (nonatomic, assign) NSInteger fw_maxLength NS_REFINED_FOR_SWIFT;
    
    /// 最大Unicode字数限制(中文为1,英文为0.5),0为无限制,二选一
    @property (nonatomic, assign) NSInteger fw_maxUnicodeLength NS_REFINED_FOR_SWIFT;
    
    /// 自定义文字改变处理句柄,默认nil
    @property (nonatomic, copy, nullable) void (^fw_textChangedBlock)(NSString *text) NS_REFINED_FOR_SWIFT;
    
    /// 文本长度发生改变,自动检测字数限制,用于代码设置text等场景
    - (void)fw_textLengthChanged NS_REFINED_FOR_SWIFT;
    
    /// 获取满足最大字数限制的过滤后的文本,无需再调用textLengthChanged
    - (NSString *)fw_filterText:(NSString *)text NS_REFINED_FOR_SWIFT;
    
    /// 设置自动完成时间间隔,默认0.5秒,和autoCompleteBlock配套使用
    @property (nonatomic, assign) NSTimeInterval fw_autoCompleteInterval NS_REFINED_FOR_SWIFT;
    
    /// 设置自动完成处理句柄,默认nil,注意输入框内容为空时会立即触发
    @property (nullable, nonatomic, copy) void (^fw_autoCompleteBlock)(NSString *text) NS_REFINED_FOR_SWIFT;
    
    /// 是否禁用长按菜单(拷贝、选择、粘贴等),默认NO
    @property (nonatomic, assign) BOOL fw_menuDisabled NS_REFINED_FOR_SWIFT;
    
    /// 自定义光标大小,不为0才会生效,默认zero不生效
    @property (nonatomic, assign) CGRect fw_cursorRect NS_REFINED_FOR_SWIFT;
    
    /// 获取及设置当前选中文字范围
    @property (nonatomic, assign) NSRange fw_selectedRange NS_REFINED_FOR_SWIFT;
    
    /// 移动光标到最后
    - (void)fw_selectAllRange NS_REFINED_FOR_SWIFT;
    
    /// 移动光标到指定位置,兼容动态text赋值
    - (void)fw_moveCursor:(NSInteger)offset NS_REFINED_FOR_SWIFT;
    
    @end

UISearchBar+FWUIKit

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UISearchBar (FWUIKit)
    
    /// 自定义内容边距,可调整左右距离和TextField高度,未设置时为系统默认
    @property (nonatomic, assign) UIEdgeInsets fw_contentInset NS_REFINED_FOR_SWIFT;
    
    /// 自定义取消按钮边距,未设置时为系统默认
    @property (nonatomic, assign) UIEdgeInsets fw_cancelButtonInset NS_REFINED_FOR_SWIFT;
    
    /// 输入框内部视图
    @property (nullable, nonatomic, weak, readonly) UITextField *fw_textField NS_REFINED_FOR_SWIFT;
    
    /// 取消按钮内部视图,showsCancelButton开启后才存在
    @property (nullable, nonatomic, weak, readonly) UIButton *fw_cancelButton NS_REFINED_FOR_SWIFT;
    
    /// 设置整体背景色
    @property (nonatomic, strong, nullable) UIColor *fw_backgroundColor NS_REFINED_FOR_SWIFT;
    
    /// 设置输入框背景色
    @property (nonatomic, strong, nullable) UIColor *fw_textFieldBackgroundColor NS_REFINED_FOR_SWIFT;
    
    /// 设置搜索图标离左侧的偏移位置,非居中时生效
    @property (nonatomic, assign) CGFloat fw_searchIconOffset NS_REFINED_FOR_SWIFT;
    
    /// 设置搜索文本离左侧图标的偏移位置
    @property (nonatomic, assign) CGFloat fw_searchTextOffset NS_REFINED_FOR_SWIFT;
    
    /// 设置TextField搜索图标(placeholder)是否居中,否则居左
    @property (nonatomic, assign) BOOL fw_searchIconCenter NS_REFINED_FOR_SWIFT;
    
    /// 强制取消按钮一直可点击,需在showsCancelButton设置之后生效。默认SearchBar失去焦点之后取消按钮不可点击
    @property (nonatomic, assign) BOOL fw_forceCancelButtonEnabled NS_REFINED_FOR_SWIFT;
    
    @end

UIActivityIndicatorView+FWViewPlugin

UINavigationController+FWTransition

FWWebView

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface UIProgressView (FWWebView)
    
    /// 设置Web加载进度,0和1自动切换隐藏。可设置trackTintColor为clear,隐藏背景色
    @property (nonatomic, assign) float fw_webProgress NS_REFINED_FOR_SWIFT;
    
    @end

FWWebViewBridge

  • Undocumented

    See more

    Declaration

    Objective-C

    @interface WKWebView (FWWebViewBridge)
    
    /// 设置Javascript桥接器强引用属性,防止使用过程中被释放
    @property (nonatomic, strong, nullable) FWWebViewJsBridge *fw_jsBridge NS_REFINED_FOR_SWIFT;
    
    /// 获取当前UserAgent,未自定义时为默认,示例:Mozilla/5.0 (iPhone; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
    @property (nonatomic, copy, readonly) NSString *fw_userAgent NS_REFINED_FOR_SWIFT;
    
    /// 获取默认浏览器UserAgent,包含应用信息,示例:Mozilla/5.0 (iPhone; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Safari/605.1.15 Example/1.0.0
    @property (class, nonatomic, copy, readonly) NSString *fw_browserUserAgent NS_REFINED_FOR_SWIFT;
    
    /// 获取默认浏览器扩展UserAgent,不含平台信息,可用于applicationNameForUserAgent,示例:Mobile/15E148 Safari/605.1.15 Example/1.0.0
    @property (class, nonatomic, copy, readonly) NSString *fw_extensionUserAgent NS_REFINED_FOR_SWIFT;
    
    /// 获取默认请求UserAgent,可用于网络请求,示例:Example/1.0.0 (iPhone; iOS 14.2; Scale/3.00)
    @property (class, nonatomic, copy, readonly) NSString *fw_requestUserAgent NS_REFINED_FOR_SWIFT;
    
    /// 清空网页缓存,完成后回调。单个网页请求指定URLRequest.cachePolicy即可
    + (void)fw_clearCache:(nullable void (^)(void))completion NS_REFINED_FOR_SWIFT;
    
    @end