2014-03-24 5 views
1

내 응용 프로그램에서는 이전에 Light를 사용하고 있던 모든 UITextField에 대해 키보드의 "어두운"모양을 사용하고 있습니다 건반.iOS 7에서 키보드 위의 사용자 정의 UIToolbar 색상 변경 (텍스트 색상 변경 만이 아님)

텍스트 필드 중 하나의 키보드 위에는 사용자가 키보드 위에있는 옵션 중 하나를 선택할 수 있도록 일부 단추가있는 사용자 지정 UIToolbar가 있습니다.

이것은 필요한 것보다 훨씬 어려워 보이지만 빛 대신에 UIToolBar를 어둡게 만들려고 노력하고 있습니다. 도구 모음은 항상 흰색이고 색상 만 변경 될 수 있습니다. 도구 모음 자체가 아니라 도구 모음의 단추.

이 도구 모음은 코드에서 생성됩니다

UIToolbar *alertToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 
                      self.view.window.frame.size.width, 44.0f)]; 

    alertToolBar.backgroundColor = [UIColor blackColor]; 
    //alertToolBar.tintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f]; 

    alertToolBar.translucent = NO; 
    alertToolBar.items = @[ [[UIBarButtonItem alloc] initWithTitle:@" GBP" 
                   style:UIBarButtonItemStyleBordered 
                  target:self 
                  action:@selector(barButtonAddText:)], 
          [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                      target:nil 
                      action:nil], 
          [[UIBarButtonItem alloc] initWithTitle:@" USD" 
                   style:UIBarButtonItemStyleBordered 
                  target:self 
                  action:@selector(barButtonAddText:)], 
          [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                      target:nil 
                      action:nil], 
          [[UIBarButtonItem alloc] initWithTitle:@" EUR" 
                   style:UIBarButtonItemStyleBordered 
                  target:self 
                  action:@selector(barButtonAddText:)], 
          [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                      target:nil 
                      action:nil], 

    self.itemTextField.inputAccessoryView = alertToolBar; 

나는 (//alertToolBar.tintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f];) 위의 주석 코드로 시도하고 바는 항상 흰색 남아 있지만 그것은 단지 색상을 변경 "버튼"입니다.

어떻게 전체 도구 모음을 검정색으로 변경할 수 있습니까?

이 문제에 대한 도움은 정말 감사하겠습니다.

답변

4

내가 barTint가 더 이상 그것을 위해 노력하고 그 경우에, 그래서 당신이 아이폰 OS 7.0 SDK를 사용하지 않습니다 같아요.

barTintColor를 사용해야합니다.

애플의 문서 :

바용하려면 tintColor의 동작은 아이폰 OS 7.0에서 변경되었습니다. 막대의 배경에 더 이상 영향을주지 않으며 UIView에 추가 된 tintColor 속성에 대해 설명한대로 동작합니다. 막대의 배경에 색을 칠하려면 -barTintColor를 사용하십시오. 이 경우

가 있어야한다 : 당신은 당신이 그것을 설정하기 전에 재산 존재를 확인 할 수 있습니다, 그래서이, 아이폰 OS 7에 추가 된

alertToolBar.barTintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f]; 
+0

이렇게 고맙습니다. barTintColor 속성을 놓쳤다는 것을 믿을 수 없습니다.하지만 이것은 절대적인 매력처럼 작용했습니다. 믿을 수 없을만큼 쉬운 질문에 대해 다시 한번 고마워하며 미안합니다! – amitsbajaj

2

은 당신이 설정하려는 생각 :

@property(nonatomic, retain) UIColor *barTintColor 
+0

하는 것으로. –

+0

대단히 감사합니다. 정말 대단 하네. 너와 알렉스의 대답을 받아 들일 수 있다면, 나는 그렇게 할 것이다. 나는 너를 투표했다. 이 덕분에 정말 도움이되었습니다. – amitsbajaj