UIButton.h


#if USE_UIKIT_PUBLIC_HEADERS || !__has_include()
//
//  UIButton.h
//  UIKit
//
//  Copyright (c) 2005-2018 Apple Inc. All rights reserved.
//

#import 
#import 
#import 
#import 
#import 
#import 
NS_ASSUME_NONNULL_BEGIN





@class UIImage, UIFont, UIColor, UIImageView, UILabel;

/* 按钮类型 <枚举> */
typedef NS_ENUM(NSInteger, UIButtonType) {
    UIButtonTypeCustom = 0,                         // 无指定类型
    UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0),  // 系统类型
    UIButtonTypeDetailDisclosure,                   // 详细信息类型(感叹号)
    UIButtonTypeInfoLight,                          // 详细信息类型(感叹号,浅色)
    UIButtonTypeInfoDark,                           // 详细信息类型(感叹号,深色)
    UIButtonTypeContactAdd,                         // 联系人添加类型(加号)
    UIButtonTypePlain API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios, watchos), // 没有模糊背景的标准系统按钮类型
    UIButtonTypeRoundedRect = UIButtonTypeSystem   // 圆角矩形样式按钮(不推荐,请改用UIButtonTypeSystem)
};



#pragma mark - 按钮Class
#pragma mark -
/*
 - UIButton
    用于响应用户交互执行自定义代码的控件
 - 概述
    当您点击按钮或选择具有焦点的按钮时,该按钮会执行附加到其本身的任何操作
    UIButton可以设置文字/图片来传达按钮的用途
    可设置颜色/字号等配置按钮的外观
 - 向界面添加按钮时,请执行以下步骤:
    实例化时设置按钮类型
    供标题字符串或图像;根据您的内容适当调整按钮大小
    将一个或多个操作方法连接到按钮
    设置自动布局规则以控制界面中按钮的大小和位置
    提供辅助功能信息和本地化字符串
 */
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIButton : UIControl 
/**
 实例化

 @param buttonType 按钮类型
 @return UIButton
 */
+ (instancetype)buttonWithType:(UIButtonType)buttonType;

// 设置 内容偏移量(默认:UIEdgeInsetsZero)
@property(nonatomic) UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR;
// 设置 文字偏移(默认:UIEdgeInsetsZero)
@property(nonatomic) UIEdgeInsets titleEdgeInsets;
// 设置 高亮状态下文字阴影(如开启阴影会从雕刻变为浮雕;默认NO)
@property(nonatomic) BOOL reversesTitleShadowWhenHighlighted;
// 设置 图片偏移(默认:UIEdgeInsetsZero)
@property(nonatomic) UIEdgeInsets imageEdgeInsets;
// 设置 高亮状态下配图是否变黑(默认:YES)
@property(nonatomic) BOOL adjustsImageWhenHighlighted;
// 设置 禁用状态下配图是否变黑(默认:YES)
@property(nonatomic) BOOL adjustsImageWhenDisabled;
// 设置 高亮状态下是否有发光反馈(默认:NO)
@property(nonatomic) BOOL showsTouchWhenHighlighted __TVOS_PROHIBITED;
// 设置主题色调
@property(null_resettable, nonatomic,strong) UIColor *tintColor NS_AVAILABLE_IOS(5_0);
// 获取 按钮类型
@property(nonatomic,readonly) UIButtonType buttonType;

// 设置 指定状态下的文字(默认1行;默认:nil)
- (void)setTitle:(nullable NSString *)title forState:(UIControlState)state;
// 设置 指定状态下的文字颜色(默认:nil,不透明白色)
- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
// 设置 指定状态下的文字阴影颜色(默认:nil,使用50%黑色)
- (void)setTitleShadowColor:(nullable UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
// 设置 指定状态下的配图(如果不同状态下配图不同,配图尺寸需要相同;默认:nil,使用50%黑色)
- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state;
// 设置 指定状态下的背景图片(默认:nil)
- (void)setBackgroundImage:(nullable UIImage *)image forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
// 设置 指定状态下的属性文本(默认1行;默认:nil)
- (void)setAttributedTitle:(nullable NSAttributedString *)title forState:(UIControlState)state NS_AVAILABLE_IOS(6_0);

// 设置 当前文字状态
- (nullable NSString *)titleForState:(UIControlState)state;
// 设置 当前文字颜色状态
- (nullable UIColor *)titleColorForState:(UIControlState)state;
// 设置 当前文字阴影颜色状态
- (nullable UIColor *)titleShadowColorForState:(UIControlState)state;
// 设置 当前配图状态
- (nullable UIImage *)imageForState:(UIControlState)state;
// 设置 当前背景图片状态
- (nullable UIImage *)backgroundImageForState:(UIControlState)state;
// 设置 当前属性文本状态
- (nullable NSAttributedString *)attributedTitleForState:(UIControlState)state NS_AVAILABLE_IOS(6_0);

/* 当按钮状态改变时,实时返回当前状态对应的属性值;属性值可能为空 */
// 获取 当前文字
@property(nullable, nonatomic,readonly,strong) NSString *currentTitle;
// 获取 当前文字颜色
@property(nonatomic,readonly,strong) UIColor  *currentTitleColor;
// 获取 当前文字阴影颜色
@property(nullable, nonatomic,readonly,strong) UIColor  *currentTitleShadowColor;
// 获取 当前配图
@property(nullable, nonatomic,readonly,strong) UIImage  *currentImage;
// 获取 当前背景图片
@property(nullable, nonatomic,readonly,strong) UIImage  *currentBackgroundImage;
// 获取 当前属性文本
@property(nullable, nonatomic,readonly,strong) NSAttributedString *currentAttributedTitle NS_AVAILABLE_IOS(6_0);

// 获取 标题文字
@property(nullable, nonatomic,readonly,strong) UILabel     *titleLabel NS_AVAILABLE_IOS(3_0);
// 获取 配图
@property(nullable, nonatomic,readonly,strong) UIImageView *imageView  NS_AVAILABLE_IOS(3_0);

// 设置 背景尺寸
- (CGRect)backgroundRectForBounds:(CGRect)bounds;
// 设置 内容尺寸(系统会根据文字尺寸和配图尺寸计算内容尺寸)
- (CGRect)contentRectForBounds:(CGRect)bounds;
// 设置 文字尺寸
- (CGRect)titleRectForContentRect:(CGRect)contentRect;
// 设置 配图尺寸
- (CGRect)imageRectForContentRect:(CGRect)contentRect;
@end





#pragma mark - 弃用 <分类>
@interface UIButton (UIButtonDeprecated)
/* 已弃用属性 */
@property(nonatomic,strong) UIFont         *font              NS_DEPRECATED_IOS(2_0, 3_0) __TVOS_PROHIBITED;
@property(nonatomic)        NSLineBreakMode lineBreakMode     NS_DEPRECATED_IOS(2_0, 3_0) __TVOS_PROHIBITED;
@property(nonatomic)        CGSize          titleShadowOffset NS_DEPRECATED_IOS(2_0, 3_0) __TVOS_PROHIBITED;
@end





#if TARGET_OS_IOS
#pragma mark - 弹出加载 <分类>
@interface UIButton (SpringLoading) 
@end
#endif





NS_ASSUME_NONNULL_END

#else
#import 
#endif

你可能感兴趣的:(UIButton.h)