//
// UIButton.h
// UIKit
//
// Copyright (c) 2005-2013, Apple Inc. All rights reserved.
//
@class UIImage, UIFont, UIColor, UIImageView, UILabel;
typedef NS_ENUM(NSInteger, UIButtonType) {
UIButtonTypeCustom = 0, // 無樣式夷恍,用戶調(diào)整
UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // 系統(tǒng)標(biāo)準(zhǔn)樣式
UIButtonTypeDetailDisclosure, // 圈圈 i 樣式
UIButtonTypeInfoLight, // 圈圈 i 樣式
UIButtonTypeInfoDark, // 圈圈 i 樣式
UIButtonTypeContactAdd, // 圈圈 + 樣式
UIButtonTypeRoundedRect = UIButtonTypeSystem, // 淘汰,用 UIButtonTypeSystem 替代
};
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIButton : UIControl <NSCoding> {
@private // 私有的
CFMutableDictionaryRef _contentLookup;
UIEdgeInsets _contentEdgeInsets; // 內(nèi)容的內(nèi)邊距
UIEdgeInsets _titleEdgeInsets; // 標(biāo)題的內(nèi)邊距
UIEdgeInsets _imageEdgeInsets; // 圖片的內(nèi)邊距
UIImageView *_backgroundView; // 內(nèi)部的背景圖片控件
UIImageView *_imageView; // 內(nèi)部的圖片控件
UILabel *_titleView; // 內(nèi)部的標(biāo)題
BOOL _initialized;
UIControlState _lastDrawingControlState;
struct {
unsigned int reversesTitleShadowWhenHighlighted:1;
unsigned int adjustsImageWhenHighlighted:1;
unsigned int adjustsImageWhenDisabled:1;
unsigned int autosizeToFit:1;
unsigned int disabledDimsImage:1;
unsigned int showsTouchWhenHighlighted:1;
unsigned int buttonType:8;
unsigned int shouldHandleScrollerMouseEvent:1;
unsigned int titleFrozen:1;
} _buttonFlags;
}
+ (id)buttonWithType:(UIButtonType)buttonType;
@property(nonatomic) UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR; // 內(nèi)容縮進(jìn)
@property(nonatomic) UIEdgeInsets titleEdgeInsets; // 文字標(biāo)題縮進(jìn)
@property(nonatomic) BOOL reversesTitleShadowWhenHighlighted; // 默認(rèn) NO. 高亮?xí)r,陰影反轉(zhuǎn)
@property(nonatomic) UIEdgeInsets imageEdgeInsets; // 圖片縮進(jìn)
@property(nonatomic) BOOL adjustsImageWhenHighlighted; // default is YES. if YES, image is drawn darker when highlighted(pressed)
@property(nonatomic) BOOL adjustsImageWhenDisabled; // default is YES. if YES, image is drawn lighter when disabled
@property(nonatomic) BOOL showsTouchWhenHighlighted; // 點(diǎn)擊時(shí)按鈕中間現(xiàn)實(shí)白色的高亮
@property(nonatomic,retain) UIColor *tintColor NS_AVAILABLE_IOS(5_0); // The tintColor is inherited through the superview hierarchy. See UIView for more information.
@property(nonatomic,readonly) UIButtonType buttonType;
# 設(shè)置內(nèi)部子控件的屬性
- (void)setTitle:(NSString *)title forState:(UIControlState)state; # 字體
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR; #字體顏色
- (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR; # 陰影
- (void)setImage:(UIImage *)image forState:(UIControlState)state;
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setAttributedTitle:(NSAttributedString *)title forState:(UIControlState)state NS_AVAILABLE_IOS(6_0);
# 這些 getters 方法只返回一種狀態(tài)的值
- (NSString *)titleForState:(UIControlState)state;
- (UIColor *)titleColorForState:(UIControlState)state;
- (UIColor *)titleShadowColorForState:(UIControlState)state;
- (UIImage *)imageForState:(UIControlState)state;
- (UIImage *)backgroundImageForState:(UIControlState)state;
- (NSAttributedString *)attributedTitleForState:(UIControlState)state NS_AVAILABLE_IOS(6_0);
# 當(dāng)按鈕的狀態(tài)改變時(shí)向叉,這些值會(huì)自動(dòng)改變邑闲,只有g(shù)et方法斩箫,只讀的
@property(nonatomic,readonly,retain) NSString *currentTitle; // 可以為空
@property(nonatomic,readonly,retain) UIColor *currentTitleColor; // 默認(rèn)是white(1,1) 退腥,不能為空
@property(nonatomic,readonly,retain) UIColor *currentTitleShadowColor; // default is white(0,0.5).
@property(nonatomic,readonly,retain) UIImage *currentImage; // 可以為空
@property(nonatomic,readonly,retain) UIImage *currentBackgroundImage; // 可以為空
@property(nonatomic,readonly,retain) NSAttributedString *currentAttributedTitle NS_AVAILABLE_IOS(6_0); # 可以為空
# return title and image views. will always create them if necessary. always returns nil for system buttons
@property(nonatomic,readonly,retain) UILabel *titleLabel NS_AVAILABLE_IOS(3_0);
@property(nonatomic,readonly,retain) UIImageView *imageView NS_AVAILABLE_IOS(3_0);
#pragma - mark 自定義按鈕惕稻,重寫這些方法調(diào)整按鈕內(nèi)部子控件的尺寸
- (CGRect)backgroundRectForBounds:(CGRect)bounds;
- (CGRect)contentRectForBounds:(CGRect)bounds;
- (CGRect)titleRectForContentRect:(CGRect)contentRect;
- (CGRect)imageRectForContentRect:(CGRect)contentRect;
@end
# 已經(jīng)失效
@interface UIButton(UIButtonDeprecated)
@property(nonatomic,retain) UIFont *font NS_DEPRECATED_IOS(2_0, 3_0); // 字體
@property(nonatomic) NSLineBreakMode lineBreakMode NS_DEPRECATED_IOS(2_0, 3_0); //
@property(nonatomic) CGSize titleShadowOffset NS_DEPRECATED_IOS(2_0, 3_0);
@end
UIButton.h
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來贺嫂,“玉大人滓鸠,你說我怎么就攤上這事±酝瘢” “怎么了哥力?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長墩弯。 經(jīng)常有香客問我吩跋,道長,這世上最難降的妖魔是什么渔工? 我笑而不...
- 正文 為了忘掉前任锌钮,我火速辦了婚禮,結(jié)果婚禮上引矩,老公的妹妹穿的比我還像新娘梁丘。我一直安慰自己,他們只是感情好旺韭,可當(dāng)我...
- 文/花漫 我一把揭開白布氛谜。 她就那樣靜靜地躺著,像睡著了一般区端。 火紅的嫁衣襯著肌膚如雪值漫。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼埃跷,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了邮利?” 一聲冷哼從身側(cè)響起弥雹,我...
- 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎近弟,沒想到半個(gè)月后缅糟,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體挺智,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡祷愉,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年窗宦,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片二鳄。...
- 正文 年R本政府宣布欺殿,位于F島的核電站寄纵,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏脖苏。R本人自食惡果不足惜程拭,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望棍潘。 院中可真熱鬧恃鞋,春花似錦、人聲如沸亦歉。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽肴楷。三九已至水由,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間阶祭,已是汗流浹背绷杜。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長得像瑰剃,于是被迫代替她去往敵國和親齿诉。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 新愛蓮說Hélène, je m'appelle Hélène/Hélène Rollès 蓍草填詞/江北客@伏羲...
- objc-runtime.h 中代碼: #include <objc/runtime.h> #include<ob...
- 前段時(shí)間朋友說人民幣貶值了晌姚, 要把存款都換成美金保值粤剧, 我估摸著算了一下自己的存款, 心里一沉挥唠, 這也讓我不得不認(rèn)...