cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/UIKitExtensions/CALayer+QMUI.h

130 lines
6.4 KiB
C
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// CALayer+QMUI.h
// qmui
//
// Created by QMUI Team on 16/8/12.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_OPTIONS (NSUInteger, QMUICornerMask) {
QMUILayerMinXMinYCorner = 1U << 0,
QMUILayerMaxXMinYCorner = 1U << 1,
QMUILayerMinXMaxYCorner = 1U << 2,
QMUILayerMaxXMaxYCorner = 1U << 3,
QMUILayerAllCorner = QMUILayerMinXMinYCorner|QMUILayerMaxXMinYCorner|QMUILayerMinXMaxYCorner|QMUILayerMaxXMaxYCorner,
};
@interface CALayer (QMUI)
/// 是否为某个 UIView 自带的 layer
@property(nonatomic, assign, readonly) BOOL qmui_isRootLayerOfView;
/// 暂停/恢复当前 layer 上的所有动画
@property(nonatomic, assign) BOOL qmui_pause;
/**
* iOS11 QMUI
* @warning layer 使 QMUIBorder border clip
* @warning 使 qmui layer clip
* @warning 使 qmui_originCornerRadius iOS 11 0
*/
@property(nonatomic, assign) QMUICornerMask qmui_maskedCorners DEPRECATED_MSG_ATTRIBUTE("请使用系统的 CALayer.maskedCornersQMUI 4.4.0 开始不再支持 iOS 10该属性无意义了后续会删除。");
/// iOS11 以下 layer 自身的 cornerRadius 一直都是 0圆角的是通过 mask 做的qmui_originCornerRadius 保存了当前的圆角
@property(nonatomic, assign, readonly) CGFloat qmui_originCornerRadius;
/**
NSShadow shadow shadowXxx shadowXxx
@note 使shadowOpacity 1 NSShadow.shadowColor alpha qmui_shadow qmui_shadow = nil
*/
@property(nonatomic, strong, nullable) NSShadow *qmui_shadow;
/// 获取指定 name 值的 layer包括 self 和 self.sublayers会一直往 sublayers 查找直到找到目标 layer。
- (nullable __kindof CALayer *)qmui_layerWithName:(NSString *)name;
/**
* sublayer sublayers
* @param sublayer layer
* @warning sublayer layer
*/
- (void)qmui_sendSublayerToBack:(CALayer *)sublayer;
/**
* sublayer sublayers
* @param sublayer layer
* @warning sublayer layer
*/
- (void)qmui_bringSublayerToFront:(CALayer *)sublayer;
/**
* CALayer CAShapeLayer CAGradientLayer便 layer 使
*/
- (void)qmui_removeDefaultAnimations;
/**
* CALayer CALayer
* @param actionsWithoutAnimation layer framebackgroundColor
* @note layer 使 qmui_removeDefaultAnimations
*/
+ (void)qmui_performWithoutAnimation:(void (NS_NOESCAPE ^)(void))actionsWithoutAnimation;
/**
* 线 CAShapeLayer
* @param lineLength 线
* @param lineSpacing 线
* @param lineWidth 线
* @param lineColor 线
* @param isHorizontal 线 YES NO
* dashPhase dashPattens
*/
+ (CAShapeLayer *)qmui_separatorDashLayerWithLineLength:(NSInteger)lineLength
lineSpacing:(NSInteger)lineSpacing
lineWidth:(CGFloat)lineWidth
lineColor:(CGColorRef)lineColor
isHorizontal:(BOOL)isHorizontal;
/**
* 线 layer PixelOne线 2线 2 UIColorSeparator CAShapeLayer
* InHorizon InVertical
*/
+ (CAShapeLayer *)qmui_separatorDashLayerInHorizontal;
+ (CAShapeLayer *)qmui_separatorDashLayerInVertical;
/**
* 线 layer PixelOne UIColorSeparator
*/
+ (CALayer *)qmui_separatorLayer;
/**
* 线 layer PixelOne TableViewSeparatorColor
*/
+ (CALayer *)qmui_separatorLayerForTableView;
@end
@interface CALayer (QMUI_DynamicColor)
/// 如果 layer 的 backgroundColor、borderColor、shadowColor 是使用 dynamic colorUIDynamicProviderColor、QMUIThemeColor 等)生成的,则调用这个方法可以重新设置一遍这些属性,从而更新颜色
/// iOS 13 系统设置里的界面样式变化Dark Mode以及 QMUIThemeManager 触发的主题变化,都会自动调用 layer 的这个方法,业务无需关心。
- (void)qmui_setNeedsUpdateDynamicStyle NS_REQUIRES_SUPER;
@end
NS_ASSUME_NONNULL_END