iOS-UIKit框架学习—UIButton

UIButton的类的一个实例,实现了在触摸屏上的按钮。触摸一个按钮拦截事件和动作消息发送到目标对象时。设定的目
和行动方法都继承自UIControl。这个类提供了方法来设置标题,图像,按钮等外观属性。通过这些访问,您可以为每个按钮状态指定一个不同的外观。

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIButton : UIControl 

// 设置按钮类型
+ (instancetype)buttonWithType:(UIButtonType)buttonType;
// 按钮内容与边缘的距离
@property(nonatomic)          UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR;
// 设置标题与边缘或插图的距离
@property(nonatomic)          UIEdgeInsets titleEdgeInsets;
// 当按钮Highlighted状态时是否标题阴影更加突出
@property(nonatomic)          BOOL         reversesTitleShadowWhenHighlighted;
// 图片与边缘的距离
@property(nonatomic)          UIEdgeInsets imageEdgeInsets;
// 当按钮Highlighted状态时是否图片突出 默认值YES
@property(nonatomic)          BOOL         adjustsImageWhenHighlighted;
// 当按钮Disabled状态时是否改变图片
@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;
// 设置指定状态下的按钮标题
- (void)setTitle:(nullable NSString *)title forState:(UIControlState)state;
// 设置指定状态下按钮标题的颜色
- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
// 设置指定状态下按钮阴影的颜色
- (void)setTitleShadowColor:(nullable UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
// 设置指定状态下按钮的图片
- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state;
// 设置指定状态下按钮的背景图片
- (void)setBackgroundImage:(nullable UIImage *)image forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
// 设置指定状态下按钮的属性标题
- (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);

// 获取当前按钮标题Label
@property(nullable, nonatomic,readonly,strong) UILabel     *titleLabel NS_AVAILABLE_IOS(3_0);
// 获取当前按钮的imageView
@property(nullable, nonatomic,readonly,strong) UIImageView *imageView  NS_AVAILABLE_IOS(3_0);
// 返回按钮的背景的CGRect
- (CGRect)backgroundRectForBounds:(CGRect)bounds;
// 返回按钮内容的CGRect
- (CGRect)contentRectForBounds:(CGRect)bounds;
// 返回按钮标题内容的CGRect
- (CGRect)titleRectForContentRect:(CGRect)contentRect;
// 返回按钮image的CGRect
- (CGRect)imageRectForContentRect:(CGRect)contentRect;
@end
// 按钮风格类型
typedef NS_ENUM(NSInteger, UIButtonType) {
    UIButtonTypeCustom = 0,                         // 自定义类型无样式
    UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0),  // 系统类型
    UIButtonTypeDetailDisclosure, // 蓝色小箭头按钮,主要做详细说明用
    UIButtonTypeInfoLight,  // 亮色感叹号
    UIButtonTypeInfoDark,   // 暗色感叹号
    UIButtonTypeContactAdd, //  十字加号按钮
    UIButtonTypeRoundedRect = UIButtonTypeSystem,   // 圆角矩形
};

你可能感兴趣的:(iOS-UIKit框架学习—UIButton)