UIView(FWUIKit)

@interface UIView (FWUIKit)

/// 视图是否可见,视图hidden为NO、alpha>0.01、window存在且size不为0才认为可见
@property (nonatomic, assign, readonly) BOOL fw_isViewVisible NS_REFINED_FOR_SWIFT;

/// 获取响应的视图控制器
@property (nonatomic, strong, readonly, nullable) __kindof UIViewController *fw_viewController NS_REFINED_FOR_SWIFT;

/// 设置额外热区(点击区域)
@property (nonatomic, assign) UIEdgeInsets fw_touchInsets NS_REFINED_FOR_SWIFT;

/// 设置自动计算适合高度的frame,需实现sizeThatFits:方法
@property (nonatomic, assign) CGRect fw_fitFrame NS_REFINED_FOR_SWIFT;

/// 计算当前视图适合大小,需实现sizeThatFits:方法
@property (nonatomic, assign, readonly) CGSize fw_fitSize NS_REFINED_FOR_SWIFT;

/// 计算指定边界,当前视图适合大小,需实现sizeThatFits:方法
- (CGSize)fw_fitSizeWithDrawSize:(CGSize)drawSize NS_REFINED_FOR_SWIFT;

/// 根据tag查找subview,仅从subviews中查找
- (nullable __kindof UIView *)fw_subviewWithTag:(NSInteger)tag NS_REFINED_FOR_SWIFT;

/// 设置阴影颜色、偏移和半径
- (void)fw_setShadowColor:(nullable UIColor *)color offset:(CGSize)offset radius:(CGFloat)radius NS_REFINED_FOR_SWIFT;

/// 绘制四边边框
- (void)fw_setBorderColor:(nullable UIColor *)color width:(CGFloat)width NS_REFINED_FOR_SWIFT;

/// 绘制四边边框和四角圆角
- (void)fw_setBorderColor:(nullable UIColor *)color width:(CGFloat)width cornerRadius:(CGFloat)radius NS_REFINED_FOR_SWIFT;

/// 绘制四角圆角
- (void)fw_setCornerRadius:(CGFloat)radius NS_REFINED_FOR_SWIFT;

/// 绘制单边或多边边框Layer。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
- (void)fw_setBorderLayer:(UIRectEdge)edge color:(nullable UIColor *)color width:(CGFloat)width NS_REFINED_FOR_SWIFT;

/// 绘制单边或多边边框Layer。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
- (void)fw_setBorderLayer:(UIRectEdge)edge color:(nullable UIColor *)color width:(CGFloat)width leftInset:(CGFloat)leftInset rightInset:(CGFloat)rightInset NS_REFINED_FOR_SWIFT;

/// 绘制单个或多个边框圆角,frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
- (void)fw_setCornerLayer:(UIRectCorner)corner radius:(CGFloat)radius NS_REFINED_FOR_SWIFT;

/// 绘制单个或多个边框圆角和四边边框,frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
- (void)fw_setCornerLayer:(UIRectCorner)corner radius:(CGFloat)radius borderColor:(nullable UIColor *)color width:(CGFloat)width NS_REFINED_FOR_SWIFT;

/// 绘制单边或多边边框视图。使用AutoLayout
- (void)fw_setBorderView:(UIRectEdge)edge color:(nullable UIColor *)color width:(CGFloat)width NS_REFINED_FOR_SWIFT;

/// 绘制单边或多边边框。使用AutoLayout
- (void)fw_setBorderView:(UIRectEdge)edge color:(nullable UIColor *)color width:(CGFloat)width leftInset:(CGFloat)leftInset rightInset:(CGFloat)rightInset NS_REFINED_FOR_SWIFT;

/// 开始倒计时,从window移除时自动取消,回调参数为剩余时间
- (dispatch_source_t)fw_startCountDown:(NSInteger)seconds block:(void (^)(NSInteger countDown))block NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 视图是否可见,视图hidden为NO、alpha>0.01、window存在且size不为0才认为可见

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL fw_isViewVisible;
  • 获取响应的视图控制器

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) __kindof UIViewController *fw_viewController;
  • 设置额外热区(点击区域)

    Declaration

    Objective-C

    @property (nonatomic) UIEdgeInsets fw_touchInsets;
  • 设置自动计算适合高度的frame,需实现sizeThatFits:方法

    Declaration

    Objective-C

    @property (nonatomic) CGRect fw_fitFrame;
  • 计算当前视图适合大小,需实现sizeThatFits:方法

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGSize fw_fitSize;
  • 计算指定边界,当前视图适合大小,需实现sizeThatFits:方法

    Declaration

    Objective-C

    - (CGSize)fw_fitSizeWithDrawSize:(CGSize)drawSize;
  • 根据tag查找subview,仅从subviews中查找

    Declaration

    Objective-C

    - (nullable __kindof UIView *)fw_subviewWithTag:(NSInteger)tag;
  • 设置阴影颜色、偏移和半径

    Declaration

    Objective-C

    - (void)fw_setShadowColor:(nullable UIColor *)color
                       offset:(CGSize)offset
                       radius:(CGFloat)radius;
  • 绘制四边边框

    Declaration

    Objective-C

    - (void)fw_setBorderColor:(nullable UIColor *)color width:(CGFloat)width;
  • 绘制四边边框和四角圆角

    Declaration

    Objective-C

    - (void)fw_setBorderColor:(nullable UIColor *)color
                        width:(CGFloat)width
                 cornerRadius:(CGFloat)radius;
  • 绘制四角圆角

    Declaration

    Objective-C

    - (void)fw_setCornerRadius:(CGFloat)radius;
  • 绘制单边或多边边框Layer。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)

    Declaration

    Objective-C

    - (void)fw_setBorderLayer:(UIRectEdge)edge
                        color:(nullable UIColor *)color
                        width:(CGFloat)width;
  • 绘制单边或多边边框Layer。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)

    Declaration

    Objective-C

    - (void)fw_setBorderLayer:(UIRectEdge)edge
                        color:(nullable UIColor *)color
                        width:(CGFloat)width
                    leftInset:(CGFloat)leftInset
                   rightInset:(CGFloat)rightInset;
  • 绘制单个或多个边框圆角,frame必须存在(添加视图后可调用layoutIfNeeded更新frame)

    Declaration

    Objective-C

    - (void)fw_setCornerLayer:(UIRectCorner)corner radius:(CGFloat)radius;
  • 绘制单个或多个边框圆角和四边边框,frame必须存在(添加视图后可调用layoutIfNeeded更新frame)

    Declaration

    Objective-C

    - (void)fw_setCornerLayer:(UIRectCorner)corner
                       radius:(CGFloat)radius
                  borderColor:(nullable UIColor *)color
                        width:(CGFloat)width;
  • 绘制单边或多边边框视图。使用AutoLayout

    Declaration

    Objective-C

    - (void)fw_setBorderView:(UIRectEdge)edge
                       color:(nullable UIColor *)color
                       width:(CGFloat)width;
  • 绘制单边或多边边框。使用AutoLayout

    Declaration

    Objective-C

    - (void)fw_setBorderView:(UIRectEdge)edge
                       color:(nullable UIColor *)color
                       width:(CGFloat)width
                   leftInset:(CGFloat)leftInset
                  rightInset:(CGFloat)rightInset;
  • 开始倒计时,从window移除时自动取消,回调参数为剩余时间

    Declaration

    Objective-C

    - (nonnull dispatch_source_t)fw_startCountDown:(NSInteger)seconds
                                             block:
                                                 (nonnull void (^)(NSInteger))block;