프로그래밍 방식으로 루프에서 프로그래밍 방식으로 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