你的位置:首页 > 软件开发 > 操作系统 > 你真的了解UIButton、UILabel 吗?

你真的了解UIButton、UILabel 吗?

发布时间:2016-08-24 17:00:06
一:首先查看一下关于UIButton的定义@class UIImage, UIFont, UIColor, UIImageView, UILabel;//设置UIButton的样式typedef NS_ENUM(NSInteger, UIButtonType) { UIButt ...

一:首先查看一下关于UIButton的定义

@class UIImage, UIFont, UIColor, UIImageView, UILabel;//设置UIButton的样式typedef NS_ENUM(NSInteger, UIButtonType) {  UIButtonTypeCustom = 0,             // 自定义,无风格  UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // standard system button  UIButtonTypeDetailDisclosure, //蓝色的披露按钮,可放在任何文字旁  UIButtonTypeInfoLight, //微件(widget)使用的小圆圈信息按钮,可以放在任何文字旁  UIButtonTypeInfoDark, //白色背景下使用的深色圆圈信息按钮  UIButtonTypeContactAdd, //蓝色加号(+)按钮,可以放在任何文字旁    UIButtonTypeRoundedRect = UIButtonTypeSystem,  // 白色圆角矩形,类似偏好设置表格单元或者地址簿卡片};NS_CLASS_AVAILABLE_IOS(2_0) @interface UIButton : UIControl <NSCoding>+ (instancetype)buttonWithType:(UIButtonType)buttonType;@property(nonatomic)     UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR; // 默认值 UIEdgeInsetsZero 所有按钮的内容周围的矩形的内侧或者外侧的边缘@property(nonatomic)     UIEdgeInsets titleEdgeInsets;        // 默认值UIEdgeInsetsZero 设置文字的EdgeInsets 在按钮标题文本周围矩形的,向内或者向外的边缘@property(nonatomic)     BOOL     reversesTitleShadowWhenHighlighted; // 默认值NO.当按钮高亮时,是否更改标题阴影@property(nonatomic)     UIEdgeInsets imageEdgeInsets;        // 默认值 UIEdgeInsetsZero 设置UIButton上的图标间距 属于按钮图片周围矩形的,向内或者向外的边缘@property(nonatomic)     BOOL     adjustsImageWhenHighlighted;  // 默认值为YES.默认情况下,在按钮被禁用时,图像会被画的颜色深一些。要禁用此功能,请将这个属性设置为NO:@property(nonatomic)     BOOL     adjustsImageWhenDisabled;    // 默认值为YES.默认情况下,按钮在被禁用时,图像会被画的颜色淡一些。要禁用此功能,请将这个属性设置为NO:@property(nonatomic)     BOOL     showsTouchWhenHighlighted;   // 默认值为 NO. 这个属性设置为YES,可令按钮在按下时发光@property(null_resettable, nonatomic,strong)  UIColor   *tintColor NS_AVAILABLE_IOS(5_0); // The tintColor is inherited through the superview hierarchy. See UIView for more information.//获取当前UIButton的UIButtonType 只读@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); // default is nil. title is assumed to be single line- (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);//获取当前UIButton的一些属性值 都为只读@property(nullable, nonatomic,readonly,strong) NSString *currentTitle;       // normal/highlighted/selected/disabled. can return nil@property(nonatomic,readonly,strong) UIColor *currentTitleColor;    // normal/highlighted/selected/disabled. always returns non-nil. default is white(1,1)@property(nullable, nonatomic,readonly,strong) UIColor *currentTitleShadowColor; // normal/highlighted/selected/disabled.@property(nullable, nonatomic,readonly,strong) UIImage *currentImage;       // normal/highlighted/selected/disabled. can return nil@property(nullable, nonatomic,readonly,strong) UIImage *currentBackgroundImage;  // normal/highlighted/selected/disabled. can return nil@property(nullable, nonatomic,readonly,strong) NSAttributedString *currentAttributedTitle NS_AVAILABLE_IOS(6_0); // normal/highlighted/selected/disabled. can return nil@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

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:你真的了解UIButton、UILabel 吗?

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录