2014-04-18 2 views
0

UIPageViewController에서 PageControl/페이지 표시기의 색상을 첫 번째 페이지에만 바꿀 수 있습니다. 필자의 경우에는 각 페이지가 다른 색상이어야하므로 PageControl/페이지 표시기를 사용하여 색상을 페이지와 일치시켜야합니다. 페이지 인덱스를 기반으로 색상을 변경하려고 시도했지만 작동하지 않습니다.UIPageViewController : 페이지 당 페이지 표시기/페이지 컨트롤의 색을 변경하십시오.

누구든지 문제를 해결하는 방법을 알고 계십니까?

- (PageContentViewController *)viewControllerAtIndex:(NSUInteger)index 
{ 


    if ([tutorialItems count] == 0) { 
     return nil; 
     } 

     // Create a new view controller and pass suitable data. 
     PageContentViewController *pageContentViewController 
     = [self.storyboard instantiateViewControllerWithIdentifier:@"PageContentViewController"]; 

     TutorialItem *tutorialItem = [tutorialItems objectAtIndex:index]; 
     pageContentViewController.imageFile = tutorialItem.tutorialImageFileName; 
     pageContentViewController.titleText = tutorialItem.tutorialTitle; 
     pageContentViewController.tutorialText = tutorialItem.tutorialText; 

     int red = tutorialItem.tutorialRedKey; 
     int green = tutorialItem.tutorialGreenKey; 
     int blue = tutorialItem.tutorialBlueKey; 

     pageContentViewController.pageIndex = index; 

     tutorialBackgroundColor = [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:1.0f]; 

     pageContentViewController.tutorialBackgroundColor = tutorialBackgroundColor; 

     UIPageControl *pageControl = [UIPageControl appearance]; 
     pageControl.pageIndicatorTintColor = [UIColor blackColor]; 
     pageControl.currentPageIndicatorTintColor = [UIColor whiteColor]; 
     pageControl.backgroundColor = [UIColor clearColor]; 
     pageContentViewController.pageControllerColor = tutorialBackgroundColor; 

     return pageContentViewController; 
    } 

답변

0

appearance 프록시 속성은 구성 요소가 처음 창에 추가 될 때만 설정됩니다. appearance 속성을 변경해도 이미 표시된 구성 요소의 속성은 변경되지 않습니다. 이미 화면에있는 구성 요소의 색을 변경하려면이를 참조하고 색을 직접 변경하거나 뷰 계층 구조에서 제거하고 다시 추가해야합니다.

You can read the documentation here

관련 인용 :

아이폰 OS가이 창에 이미 뷰의하지 변화 모양을 수행하는보기 창을 입력하면 모양이 변경 적용됩니다. 현재 창에있는보기의 모양을 으로 변경하려면보기 계층에서 보기를 제거한 다음 다시 넣습니다.

관련 문제