2013-03-15 7 views
3

enter image description here 내 UIDatePicker의 배경이 검정색 (전체 화면의 배경색이 아마도 검은 색이기 때문에)이지만이 UIDatePicker의 배경에 흰색을 넣고 싶습니다.Xcode - UIDatePicker 배경색

서브 클래 싱없이 배경색을 변경할 수있는 방법이 있습니까?

답변

0

일반적으로, 나는 당신이 yourDatePickerRef.backgroundColor = [UIColor whiteColor]; 같은 라인을 통해 프로그래밍 방식으로 배경을 설정할 수 UIDatePicker inherits from UIView 있다는 것을 말할 것입니다,하지만 그것은 밝혀 - according to this related question - UIDatePicker 그것의 내부 파단 의 번호가 일부의 배경 화면입니다.

배경색을 흰색으로 설정해야하는 하위보기입니다 (현재 설정되어있는 것과는 달리).

네, 조금은 고통 스럽지만, UIDatePicker는 잠재적으로 개체의 모양을 사용자 정의 할 수 있다는 점에서 강력합니다.

+0

감사합니다! 방금이 하위보기의 모든 레이어를 살펴 보았습니다. 개체 인덱스를 변경해야했습니다. 4, 10 및 16을 적절한 색으로 변경해야합니다. 애플이 주문을 바꾸지 않길 바래. : P – Rocky

0

피커 뒤에 일반 UIView을 추가하지 않는 이유는 무엇입니까? 뷰의 배경색을 흰색으로 설정하십시오. 보기에 피커와 동일한 프레임을 지정하십시오. (마이클의 대답에 귀하의 코멘트에 따라)

:

UIDatePicker의 개인 파단 주위에 파고는 위험합니다. 그것은 언제든지 깨질 수 있습니다. 피커가 3 개가 아닌 2 개의 구성 요소 만 가지므로 AM/PM을 사용하지 않는 로켈이있는 장치에서 사용되는 날짜 선택 도구의 경우 솔루션이 거의 손상되지 않습니다.

1

동일한 문제가있었습니다. 난 그냥있는 UIView를 생성하고 UIDatePicker

datePickerBackground = [[UIView alloc] initWithFrame:myDatePickerView.frame]; 
    datePickerBackground.backgroundColor = [UIColor whiteColor]; 
    [self.view insertSubview:datePickerBackground belowSubview:myDatePickerView]; 
뒤에 넣어

나는 UIView의 * datePickerBackground 선언; 내 수업에서. 나는이 동일한 ViewController를 재사용하므로 unLoad에서 datePickerBackground를 nil로 설정했다.

5
datePickerName.backgroundColor = [UIColor grayColor]; 
0

간단한 따라 다음 단계

  • 먼저 당신은 당신의 위임을 설정합니다. 시간 파일 같은 :

    UIPickerViewDelegate, UIPickerViewDataSource

  • 다음

    당신이 날짜 선택기를 만들어 그 라인를 추가

    YourDatePicker = [[UIDatePicker의 ALLOC] 초기화]
    YourDatePicker.backgroundColor = [UIColor whiteColor];

  • 귀하의 경우 색상은 흰색이지만 원하는대로 변경할 수 있습니다.

2

목적 C

datePicker.backgroundColor = [UIColor greenColor] 

SWIFT

DatePicker.backgroundColor = UIColor.blueColor() 
DatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor") 
DatePicker.setValue(0.8, forKeyPath: "alpha")