0

UIButtonのcurrentBackgroundImageプロパティについて知っていますが、UIButtonから単純なbackgroundColorを取得する方法はありますか?

4

2 に答える 2

5

私があなたの質問を正しく理解した場合、あなたはボタンの背景色を取得してそれを保存したいだけですか?

UIColor* buttonColor = button.backgroundColor;

backgroundColorcopyセッターとゲッターの両方を備えたプロパティです。ドット表記を使用して、物事を単純化できます。

于 2012-12-05T02:50:44.633 に答える
0

あなたの質問によると、答えは「はい」または「いいえ」のみでなければなりません。

ただし、説明したいのですが、はい、UIButtonの背景色を取得して設定できます。

UIButton *blueButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//for setting
blueButton.backgroundColor = [UIColor colorWithRed:0.0f 
                                             green:0.0f
                                              blue:1.0 
                                               pha:1.0]; 
//for getting
UIColor *myBlueButtonColor = blueButton.backgroundColor;
于 2012-12-05T04:02:05.223 に答える