cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/QMUIComponents/QMUINavigationTitleView.h

184 lines
7.7 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.
*/
//
// QMUINavigationTitleView.h
// qmui
//
// Created by QMUI Team on 14-7-2.
//
#import <UIKit/UIKit.h>
#import "QMUIButton.h"
@class QMUINavigationTitleView;
@protocol QMUINavigationTitleViewDelegate <NSObject>
@optional
/**
titleView titleView.userInteractionEnabled = YES 使 QMUINavigationTitleViewAccessoryTypeDisclosureIndicator
@param titleView titleView
@param isActive titleView
*/
- (void)didTouchTitleView:(QMUINavigationTitleView *)titleView isActive:(BOOL)isActive;
/**
titleView [titleView setActive:]
@param active
@param titleView titleView
*/
- (void)didChangedActive:(BOOL)active forTitleView:(QMUINavigationTitleView *)titleView;
@end
/// 设置title和subTitle的布局方式默认是水平布局。
typedef NS_ENUM(NSInteger, QMUINavigationTitleViewStyle) {
QMUINavigationTitleViewStyleDefault, // 水平
QMUINavigationTitleViewStyleSubTitleVertical // 垂直
};
/// 设置titleView的样式默认没有任何修饰
typedef NS_ENUM(NSInteger, QMUINavigationTitleViewAccessoryType) {
QMUINavigationTitleViewAccessoryTypeNone, // 默认
QMUINavigationTitleViewAccessoryTypeDisclosureIndicator // 有下拉箭头
};
/**
* UIViewController self.navigationItem.titleView -[UIViewController setTitle:] -[UINavigationItem setTitle:] QMUINavigationTitleView
*
* UIViewController 使
*
* loadingaccessoryView
*
* titleView `userInteractionEnabled` `YES`
*
* titleView
*
* 1. 使 UIControl addTarget:action:forControlEvents:
* 2. 使 QMUINavigationTitleViewDelegate titleView.accessoryType 使 accessoryView active
*/
@interface QMUINavigationTitleView : UIControl
@property(nonatomic, weak) id<QMUINavigationTitleViewDelegate> delegate;
@property(nonatomic, assign) QMUINavigationTitleViewStyle style;
@property(nonatomic, assign, getter=isActive) BOOL active;
@property(nonatomic, assign) CGFloat maximumWidth UI_APPEARANCE_SELECTOR;
#pragma mark - Titles
@property(nonatomic, strong, readonly) UILabel *titleLabel;
@property(nonatomic, copy) NSString *title;
@property(nonatomic, strong, readonly) UILabel *subtitleLabel;
@property(nonatomic, copy) NSString *subtitle;
/// 当 tintColor 发生变化时是否要自动把 titleLabel、subtitleLabel、loadingView 的颜色也更新为 tintColor 的色值,默认为 YES如果你自己修改了 titleLabel、subtitleLabel、loadingView 的颜色,需要把这个值置为 NO
@property(nonatomic, assign) BOOL adjustsSubviewsTintColorAutomatically UI_APPEARANCE_SELECTOR;
/// 水平布局下的标题字体,默认为 NavBarTitleFont
@property(nonatomic, strong) UIFont *horizontalTitleFont UI_APPEARANCE_SELECTOR;
/// 水平布局下的副标题的字体,默认为 NavBarTitleFont
@property(nonatomic, strong) UIFont *horizontalSubtitleFont UI_APPEARANCE_SELECTOR;
/// 垂直布局下的标题字体,默认为 UIFontMake(15)
@property(nonatomic, strong) UIFont *verticalTitleFont UI_APPEARANCE_SELECTOR;
/// 垂直布局下的副标题字体,默认为 UIFontLightMake(12)
@property(nonatomic, strong) UIFont *verticalSubtitleFont UI_APPEARANCE_SELECTOR;
/// 标题的上下左右间距,当标题不显示时,计算大小及布局时也不考虑这个间距,默认为 UIEdgeInsetsZero
@property(nonatomic, assign) UIEdgeInsets titleEdgeInsets UI_APPEARANCE_SELECTOR;
/// 副标题的上下左右间距,当副标题不显示时,计算大小及布局时也不考虑这个间距,默认为 UIEdgeInsetsZero
@property(nonatomic, assign) UIEdgeInsets subtitleEdgeInsets UI_APPEARANCE_SELECTOR;
#pragma mark - Loading
@property(nonatomic, strong, readonly) UIActivityIndicatorView *loadingView;
/*
* loadingloading才有可能显示出来NO
*/
@property(nonatomic, assign) BOOL needsLoadingView;
/*
* `needsLoadingView`loading的显示和隐藏YES
*
* @see needsLoadingView
*/
@property(nonatomic, assign) BOOL loadingViewHidden;
/*
* YES则title居中loading放在title的左边title右边有一个跟左边loading一样大的占位空间 loading NOloading和title整体居中YES
*/
@property(nonatomic, assign) BOOL needsLoadingPlaceholderSpace;
@property(nonatomic, assign) CGSize loadingViewSize UI_APPEARANCE_SELECTOR;
/*
* loading距离右边的距离
*/
@property(nonatomic, assign) CGFloat loadingViewMarginRight UI_APPEARANCE_SELECTOR;
#pragma mark - Accessory
/*
* accessoryView不为空时QMUINavigationTitleViewAccessoryType设置无效None
*/
@property(nonatomic, strong) UIView *accessoryView;
/*
* accessoryView为空时才有效
*/
@property(nonatomic, assign) QMUINavigationTitleViewAccessoryType accessoryType;
/*
* accessoryView的位置
*/
@property(nonatomic, assign) CGPoint accessoryViewOffset UI_APPEARANCE_SELECTOR;
/*
* YES则title居中`accessoryView`title的左边或右边NO`accessoryView`title整体居中NO
*/
@property(nonatomic, assign) BOOL needsAccessoryPlaceholderSpace;
/*
* accessoryView subtitle AccessoryView
* @warn QMUINavigationTitleViewStyleSubTitleVertical
*/
@property(nonatomic, strong) UIView *subAccessoryView;
/*
* subAccessoryView
*/
@property(nonatomic, assign) CGPoint subAccessoryViewOffset UI_APPEARANCE_SELECTOR;
/*
* needsAccessoryPlaceholderSpace subtitle
*/
@property(nonatomic, assign) BOOL needsSubAccessoryPlaceholderSpace;
/*
*
*/
- (instancetype)initWithStyle:(QMUINavigationTitleViewStyle)style;
@end
@interface UIView (QMUINavigationTitleView)
/// 标记当前 view 是用于自定义的导航栏标题QMUI 可以帮你自动处理系统的一些布局 bug。对于 QMUINavigationTitleView 而言默认值为 YES其他 UIView 默认值为 NO
@property(nonatomic, assign) BOOL qmui_useAsNavigationTitleView;
@end