あなただけのiOS 5ターゲットにしている場合は、私は強くWWDC 2011セッションビデオのを必要Session 114 - Customizing the Appearance of UIKit Controls開発者のログインを見ることをお勧めします。
アプリ全体のスタイリングについて詳しく説明しています。
私はyujisアイデアを変更したい:ボタンをセットアップするためにUIButtonに
の.hをcategoryを使用してください。
@interface UIButton (MyStyling)
-(void)configureMyButtonStyle;
//other methods for more fine-grained control
@end
.M
@implementation UIButton (MyStyling)
-(void)configureMyButtonStyle
{
[self setBackgroundColor:[UIColor colorWithRed:…]];
[self setTitleColor: [UIColor colorWithRed:…] forState: UIControlStateNormal];
//…
}
@end
今、あなたはまた、いくつかのスタイルを区別するために、いくつかのパラメータで解析することができます。もちろん、[aButton configureMyButtonStyle]
を呼び出すことができます。
-(void)configureMyButtonForStyle:(NSInteger)style
{
if(style == 1){
//…
} else if(style == 2) {
//..
} else {
//fallback style
}
}
使用:
[aButton configureMyButtonForStyle:1];
うわー - これは素晴らしいようです - 頭のおかげで! – resedasue
と別の編集... – vikingosegundo
ありがとうございます - カテゴリを設定することは意味があります。特に、いくつかの異なるビューで同じボタンのスタイリングを使用するためです。そして、私があなたのリンクの礼儀について学んだその外観プロキシも、別のオプションを提供するかもしれません。 – resedasue