UIButton機能区分とメソッドには以下があります。
+ buttonWithType:ボタンのタイトル設定buttonTypepropertyfontpropertylineBreakModepropertytitleShadowOffsetpropertytitleLabelpropertyreversesTitleShadowWhenHighlightedproperty– setTitle:forState:– setTitleColor:forState:– setTitleShadowColor:forState:– titleColorForState:– titleForState:– titleShadowColorForState:
ボタンのイメージ設定
adjustsImageWhenHighlightedpropertyadjustsImageWhenDisabledpropertyshowsTouchWhenHighlightedproperty– backgroundImageForState:– imageForState:– setBackgroundImage:forState:指定されたボタンstateで使用するバックグラウンドイメージをセットする。Parametersimage指定されたstateで使用するためのバックグラウンドイメージstate指定されたイメージを使用する状態(state)。UIControlStateで値が宣言される。一般に、もしプロパティで状態が指定されていない場合UIControlStateNormalが値として使用される。そしてプロパティはシステムのデフォルト値となる。そのため最低限Normal stateの値はセットする必要があある。
– setImage:forState:
ボタンの余白設定
現在の状態の取得
ボタンの余白設定
contentEdgeInsets property titleEdgeInsets property imageEdgeInsets property現在の状態の取得
currentTitle property currentTitleColor property currentTitleShadowColor property currentImage property currentBackgroundImage property imageView propertyボタンの寸法の取得
– backgroundRectForBounds:– contentRectForBounds:– titleRectForContentRect:– imageRectForContentRect:
UIControlStateNormal
通常のデフォルトのコントロール状態。使用可能な状態ですが、選択/ハイライトはされていない。
UIControlStateHighlighted
ハイライトされた状態。コントロールは、タッチ入力時とタッチ状態から出た時、トラッキング状態から出た時、タッチアップされた時にこの状態に入る。highlighted プロパティを通じ、この値を取得し、セットすることができる。
UIControlStateDisabled
コントロール状態を無効にする。 現在コントロールが利用不可となっていることを示す。enabled プロパティを通じ、この値を取得し、セットすることができる。
UIControlStateSelected
コントロール状態を選択する。 多くのコントロールではこの状態は振る舞いや見え方を変更しないが、UISwitchControl等のサブクラスに影響を及ぼす。selectedプロパティを通じ、この値を取得し、セットすることができる。
UIControlStateApplication
アプリケーションが使用することができる追加のコントロール状態のフラグ
UIControlStateReserved
内部のフレームワークが使用するための予約されたコントロール状態のフラグ
----------------- sample code -----------------
-(void)viewDidLoad{
UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
UIImage *stretchableButtonImageNormal = [buttonImageNormal
strectchableImageWithLeftCapWidth:12 topCapHeitht:0];
[doSomethingButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[doSomethingButton setBackgroundImage:strectchableImagePressed forState:UIControlStateHighlighted];
}
---------------------------------
0 件のコメント:
コメントを投稿