プログラムで「連絡先を追加」ボタンの色を変更したいですか?
1365 次
2 に答える
3
UIButton のプロパティ tintColor を使用します。
UIButton* addButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.tintColor = [UIColor whiteColor];
于 2013-11-27T12:06:14.633 に答える
2
ボタンのタイプがカスタムであることを確認してください。次に、次の操作を行うと、丸みを帯びた角が元に戻ります。
[self.myButton.layer setCornerRadius:8.0f];
[self.myButton.layer setMasksToBounds:YES];
[self.myButton.layer setBorderWidth:1.0f];
[self.myButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
self.myButton.backgroundColor = [UIColor redColor];
個人的には、無地のグラデーション ボタンの大ファンです... また、背景色にはさまざまな状態がありませんが、背景画像にはさまざまな状態があります。
[self.myButton setBackgroundImage:[UIImage imageNamed:@"gradient.png"] forState:UIControlStateNormal];
画像を使用すると、選択するとボタンが暗くなります (または、状態ごとに異なる背景画像を提供して、別のことを行うこともできます)。これは背景色では発生しません。背景は常に同じままで、ボタンのラベルのみが状態ごとに変化します。
于 2012-08-24T08:53:01.540 に答える