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

97 lines
7.2 KiB
C
Raw 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.
*/
//
// UITableViewCell+QMUI.h
// QMUIKit
//
// Created by QMUI Team on 2018/7/5.
//
#import <UIKit/UIKit.h>
#import "UITableView+QMUI.h"
NS_ASSUME_NONNULL_BEGIN
/// 用于在 @c qmui_separatorInsetsBlock @c qmui_topSeparatorInsetsBlock 里作为”不需要分隔线“的标志返回
extern const UIEdgeInsets QMUITableViewCellSeparatorInsetsNone;
@interface UITableViewCell (QMUI)
/// 获取当前 cell 所在的 tableViewiOS 13 下在 cellForRow(heightForRow 内不可以) 内 init 完 cell 就可以获取到值,而 iOS 12 及以下只能在 cell 即将显示时(也即 willDisplay 之前)才能获取到值
@property(nonatomic, weak, readonly, nullable) UITableView *qmui_tableView;
/// 当 cell 内部可以访问到 tableView 时就会调用这个 block内部会做过滤tableView 指针不变就不会再调用
/// @note 一般情况下 iOS 13 及以后的版本cellForRow 里的 cell init 完立马就可以访问到 tableView 了,而其他低版本要等到 willDisplayCell 之前才可以访问到。
@property(nonatomic, copy, nullable) void (^qmui_didAddToTableViewBlock)(__kindof UITableView *tableView, __kindof UITableViewCell *cell);
/// 获取当前 cell 初始化时用的 style 值
@property(nonatomic, assign, readonly) UITableViewCellStyle qmui_style;
/// cell 在当前 section 里的位置,在 willDisplayCell 时可以使用cellForRow 里只能自己使用 -[UITableView qmui_positionForRowAtIndexPath:] 获取。
@property(nonatomic, assign, readonly) QMUITableViewCellPosition qmui_cellPosition;
/**
cell cell willDisplayCell block tableView 便 tableView cell cell PlainGrouped cell.qmui_cellPosition cell section
@note block UITableViewDelegate willDisplayCell
*/
@property(nonatomic, copy, nullable) void (^qmui_configureStyleBlock)(__kindof UITableView *tableView, __kindof UITableViewCell *cell, NSIndexPath * _Nullable indexPath);
/**
cell moveRow 0.8 alpha + cellForRow move block cell.qmui_shadow
@warning cell block cell moveRow clipsToBounds NOalpha 1 UITableView subview cell 便 block cell
*/
@property(nonatomic, copy, nullable) void (^qmui_configureReorderingStyleBlock)(__kindof UITableView *tableView, __kindof UITableViewCell *aCell, BOOL isReordering);
/**
cell 线 block 便 UITableViewStyle QMUITableViewCellPosition cell.qmui_cellPosition 线线 cell block insets cell insets 线线 QMUITableViewCellSeparatorInsetsNone
@note tableView.separatorStyle != UITableViewCellSeparatorStyleNone 线线 tableView.separatorColor UITableView 线 cell 线/ cell 线 block 线线
@warning 线 cell cell.textLabel subviews cell.contentView 线 subviews
*/
@property(nonatomic, copy, nullable) UIEdgeInsets (^qmui_separatorInsetsBlock)(__kindof UITableView *tableView, __kindof UITableViewCell *cell);
/**
cell 线 @c qmui_separatorInsetsBlock
*/
@property(nonatomic, copy, nullable) UIEdgeInsets (^qmui_topSeparatorInsetsBlock)(__kindof UITableView *tableView, __kindof UITableViewCell *cell);
/// 设置 cell 点击时的背景色,如果没有 selectedBackgroundView 会创建一个。
/// @warning 请勿再使用 self.selectedBackgroundView.backgroundColor 修改,因为 QMUITheme 里会重新应用 qmui_selectedBackgroundColor会覆盖 self.selectedBackgroundView.backgroundColor 的效果。
@property(nonatomic, strong, nullable) UIColor *qmui_selectedBackgroundColor;
/// setHighlighted:animated: 方法的回调 block
@property(nonatomic, copy, nullable) void (^qmui_setHighlightedBlock)(BOOL highlighted, BOOL animated);
/// setSelected:animated: 方法的回调 block
@property(nonatomic, copy, nullable) void (^qmui_setSelectedBlock)(BOOL selected, BOOL animated);
/**
cell accessoryView editingAccessoryView -> accessoryView -> accessoryView -> accessoryView
@note UITableViewCellAccessoryDetailDisclosureButtoniOS 12 UITableViewCellDetailDisclosureView iOS 13 view qmui_accessoryView view
*/
@property(nonatomic, strong, readonly, nullable) __kindof UIView *qmui_accessoryView;
@end
@interface UITableViewCell (QMUI_Styled)
/// 按照 QMUI 配置表的值来将 cell 设置为全局统一的样式
- (void)qmui_styledAsQMUITableViewCell;
@property(nonatomic, strong, readonly, nullable) UIColor *qmui_styledTextLabelColor;
@property(nonatomic, strong, readonly, nullable) UIColor *qmui_styledDetailTextLabelColor;
@property(nonatomic, strong, readonly, nullable) UIColor *qmui_styledBackgroundColor;
@property(nonatomic, strong, readonly, nullable) UIColor *qmui_styledSelectedBackgroundColor;
@property(nonatomic, strong, readonly, nullable) UIColor *qmui_styledWarningBackgroundColor;
@end
NS_ASSUME_NONNULL_END