iphone - How do I make the bottom bar with dots of a UIPageViewController translucent? -
i'm in process of making tutorial, , i'm trying emulate style of path's tutorial so:
http://www.appcoda.com/wp-content/uploads/2013/06/uipageviewcontroller-tutorial-screen.jpg
my issue if set delegate method so:
- (nsinteger)presentationcountforpageviewcontroller:(uipageviewcontroller *)pageviewcontroller { // number of items reflected in page indicator. return 5; }
then stupid black bar under dots:
http://i.stack.imgur.com/puedh.png
is there way make bar translucent in way thats similar setting uinavigationbar translucent?
it easy make work. have make pageviewcontroller taller, , place pagecontrol xib file. trick put pagecontrol in foreground (and other common controls) @ beginning, , update content of pagecontrol pageviewcontroller. here code:
- (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. self.pagecontroller = [[uipageviewcontroller alloc] initwithtransitionstyle:uipageviewcontrollertransitionstylescroll navigationorientation:uipageviewcontrollernavigationorientationhorizontal options:nil]; self.pagecontroller.datasource = self; // need cover control making frame taller (+ 37) [[self.pagecontroller view] setframe:cgrectmake(0, 0, [[self view] bounds].size.width, [[self view] bounds].size.height + 37)]; tutorialpageviewcontroller *initialviewcontroller = [self viewcontrolleratindex:0]; nsarray *viewcontrollers = [nsarray arraywithobject:initialviewcontroller]; [self.pagecontroller setviewcontrollers:viewcontrollers direction:uipageviewcontrollernavigationdirectionforward animated:no completion:nil]; [self addchildviewcontroller:self.pagecontroller]; [[self view] addsubview:[self.pagecontroller view]]; [self.pagecontroller didmovetoparentviewcontroller:self]; // bring common controls foreground (they hidden since frame taller) [self.view bringsubviewtofront:self.pcdots]; [self.view bringsubviewtofront:self.btnskip]; } - (uiviewcontroller *)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller viewcontrollerbeforeviewcontroller:(uiviewcontroller *)viewcontroller { nsuinteger index = [(tutorialpageviewcontroller *)viewcontroller index]; [self.pcdots setcurrentpage:index]; if (index == 0) { return nil; } index--; return [self viewcontrolleratindex:index]; } - (uiviewcontroller *)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller viewcontrollerafterviewcontroller:(uiviewcontroller *)viewcontroller { nsuinteger index = [(tutorialpageviewcontroller *)viewcontroller index]; [self.pcdots setcurrentpage:index]; index++; if (index == 3) { return nil; } return [self viewcontrolleratindex:index]; } - (tutorialpageviewcontroller *)viewcontrolleratindex:(nsuinteger)index { tutorialpageviewcontroller *childviewcontroller = [[tutorialpageviewcontroller alloc] initwithnibname:@"tutorialpageviewcontroller" bundle:nil]; childviewcontroller.index = index; return childviewcontroller; } - (nsinteger)presentationcountforpageviewcontroller:(uipageviewcontroller *)pageviewcontroller { // number of items reflected in page indicator. nsinteger tutorialsteps = 3; [self.pcdots setnumberofpages:tutorialsteps]; return tutorialsteps; } - (nsinteger)presentationindexforpageviewcontroller:(uipageviewcontroller *)pageviewcontroller { // selected item reflected in page indicator. return 0; }
Comments
Post a Comment