私はループでプログラムでUIButton
を作成していますが、ボタンの背景色を設定する際に問題があります。Iphone UIButton背景色
ボタンの色は常に白く表示されます。 しかし、私は背景色で2色しか使用していないのでうまく動作します。 例:赤:255緑:0青:200
ここにボタンを追加するためのコードがあります。
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(80, 20 + (i*75), 200, 75);
button.layer.cornerRadius = 10;
button.layer.borderWidth = 1;
[button setTitle:@"saf" forState:UIControlStateNormal];
[button addTarget:self action:@selector(moveLocation:) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundColor:[UIColor colorWithRed:255 green:180 blue:200 alpha:1]];
button.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[scrollView addSubview:button];
+1絶対に。合意したコンポーネントは0〜255ではなく0〜1です。 – Steve
ありがとう!私はいつもパーセンテージ値の代わりにrgbの数値であったが、 – Tim