内容の保証はできません。
/System/Library/frameWorks/UIKit.framework
クラス UIButton †
NSObject
|
+--UIResponder
|
+--UIView
|
+--UIControl
|
+--UIButton
概要 †
UIButtonクラスは、スクリーン上にボタンを設置するための手段を提供するUIControlサブクラスです。ボタンは、タップされるとそのタッチイベントを傍受し、対象のオブジェクトにアクションメッセージを送信します。ターゲットとアクションを設定するためのメソッドはUIControlクラスから継承されています。このクラスは、ボタンのタイトル、イメージ、その他の属性のプロパティを設定するメソッドを提供します。setメソッドを使用することで、ボタンのそれぞれの状態に対応した異なる外観を指定することが出来ます。
インデックス †
インスタンスの作成 †
+ buttonWithType:
タイトルの設定 †
buttonType property
font property
lineBreakMode property
titleShadowOffset property
titleLabel property 3.0b以降
reversesTitleShadowWhenHighlighted property
– setTitle:forState:
– setTitleColor:forState:
– setTitleShadowColor:forState:
– titleColorForState:
– titleForState:
– titleShadowColorForState:
イメージの設定 †
adjustsImageWhenHighlighted property
adjustsImageWhenDisabled property
showsTouchWhenHighlighted property
– backgroundImageForState:
– imageForState:
– setBackgroundImage:forState:
– setImage:forState:
ボタンの余白を設定 †
titleEdgeInsets property
imageEdgeInsets property
contentEdgeInsets property
ボタンの状態を取得 †
currentTitle property
currentTitleColor property
currentTitleShadowColor property
currentImage property
currentBackgroundImage property
imageView property 3.0b以降
ボタンの寸法を取得 †
– backgroundRectForBounds:
– contentRectForBounds:
– titleRectForContentRect:
– imageRectForContentRect:
プロパティ †
adjustsImageWhenDisabled †
ボタンが無効である時イメージが変更されるかどうかを決定する。
デフォルト:YES
@property(nonatomic) BOOL adjustsImageWhenDisabled
adjustsImageWhenHighlighted †
ボタンがハイライトされている時イメージが変更されるかどうかを決定する。
デフォルト:YES
@property(nonatomic) BOOL adjustsImageWhenHighlighted
buttonType †
ボタンタイプを返す。(読み取りのみ)
@property(nonatomic, readonly) UIButtonType buttonType
contentEdgeInsets †
現在のエッジ(余白)を指定する。
デフォルト:UIEdgeInsetsZero
@property(nonatomic) UIEdgeInsets contentEdgeInsets
currentBackgroundImage †
ボタンの現在の背景イメージを返す。(読み取りのみ)
@property(nonatomic, readonly, retain) UIImage *currentBackgroundImage
currentImage †
ボタンの現在のイメージを返す。(読み取りのみ)
@property(nonatomic, readonly, retain) UIImage *currentImage
currentTitle †
ボタンの現在のタイトルを返す。(読み取りのみ)
@property(nonatomic, readonly, retain) NSString *currentTitle
currentTitleColor †
ボタンの現在のタイトル色を返す。(読み取りのみ)
@property(nonatomic, readonly, retain) UIColor *currentTitleColor
currentTitleShadowColor †
ボタンのタイトルの影の色を返す。(読み取りのみ)
@property(nonatomic, readonly, retain) UIColor *currentTitleShadowColor
font †
ボタンのテキストに使用されているフォントを指定する。
デフォルト:nil(システムフォント)
@property(nonatomic, retain) UIFont *font
imageEdgeInsets †
イメージのエッジ(余白)を設定する。
デフォルト:UIEdgeInsetsZero
@property(nonatomic) UIEdgeInsets imageEdgeInsets
imageView †
ボタンのイメージビューを返す。 (読み取りのみ)
@property(nonatomic,readonly,retain) UIImageView *imageView
lineBreakMode †
テキストを挿入する時のラインブレークモードを指定する。
デフォルト:UILineBreakModeMiddleTruncation
@property(nonatomic) UILineBreakMode lineBreakMode
reversesTitleShadowWhenHighlighted †
ボタンがハイライトされた時、影を変更するかを決定する。
デフォルト:NO
@property(nonatomic) BOOL reversesTitleShadowWhenHighlighted
showsTouchWhenHighlighted †
ボタンがタップされた時に鮮やかになる(中央にかけて光る)かどうかを指定する。
デフォルト:NO
@property(nonatomic) BOOL showsTouchWhenHighlighted
titleEdgeInsets †
タイトルのエッジを設定する。
デフォルト:UIEdgeInsetsZero
@property(nonatomic) UIEdgeInsets titleEdgeInsets
titleLabel †
ボタンのcurrentTitleプロパティの値を表示するためのビューを返す。(読み取りのみ)
使い方
UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
@property(nonatomic,readonly,retain) UILabel *titleLabel
titleShadowOffset †
レシーバのタイトルに使用されている影のオフセットを返す。
デフォルト:CGSizeZero
@property(nonatomic) CGSize titleShadowOffset
クラスメソッド †
buttonWithType †
ボタンタイプを指定してボタンのインスタンスを作成する。
+ (id)buttonWithType:(UIButtonType)buttonType
インスタンスメソッド †
backgroundImageForState: †
指定したボタンの状態に使用されている背景イメージを返す。
- (UIImage *)backgroundImageForState:(UIControlState)state
backgroundRectForBounds: †
レシーバの背景の短形を返す。
- (CGRect)backgroundRectForBounds:(CGRect)bounds
contentRectForBounds: †
レシーバのコンテンツ(全縁)の短形を返す。
- (CGRect)contentRectForBounds:(CGRect)bounds
imageForState: †
指定したボタンの状態に使用されているイメージを返す。
- (UIImage *)imageForState:(UIControlState)state
imageRectForContentRect: †
レシーバのイメージの短形を返す。
- (CGRect)imageRectForContentRect:(CGRect)contentRect
setBackgroundImage:forState: †
指定したボタンの状態に使用される背景イメージを設定する。
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state
setImage:forState: †
指定したボタンの状態に使用されるイメージを設定する。
- (void)setImage:(UIImage *)image forState:(UIControlState)state
setTitle:forState: †
指定したボタンの状態に使用されるタイトルを設定する。
- (void)setTitle:(NSSTring *)title forState:(UIControlState)state
setTitleColor:forState: †
指定したボタンの状態に使用されるタイトル色を設定する。
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state
setTitleShadowColor:forState: †
指定したボタンの状態に使用されるタイトルの影の色を設定する。
- (void)setTitleShadowColor:(UIColor *) forState:(UIControlState)state
titleColorForState: †
指定したボタンの状態に使用されているタイトル色を返す。
- (UIColor *)titleColorForState:(UIControlState)state
titleForState: †
指定したボタンの状態に使用されているタイトルを返す。
- (NSString *)titleForState:(UIControlState)state
titleRectForContentRect: †
レシーバのタイトルの短形を返す。
- (CGRect)titleRectForContentRect:(CGRect)contentRect
titleShadowColorForState: †
指定したボタンの状態に使用されているタイトルの影の色を返す。
- (UIColor *)titleShadowColorForState:(UIControlState)state
コンスタント †
UIButtonType †
ボタンのスタイルを決定する。
| ボタンタイプ | 外観 |
| UIButtonTypeCustom | - |
| UIButtonTypeRoundRect |  |
| UIButtonTypeDetailDisclosure |  |
| UIButtonTypeInfoLight |  |
| UIButtonTypeInfoDark |  |
| UIButtonTypeContactAdd |  |