mutualmobile / MMDrawerController

A lightweight, easy to use, Side Drawer Navigation Controller
MIT License
6.76k stars 1.38k forks source link

Disable vertical separator between drawer and center view #129

Open davidknezic opened 11 years ago

davidknezic commented 11 years ago

Hello! I'm writing an app which will use a left drawer containing the application menu.

By coloring my navigation bar and the drawer background with the same dark colors and leaving my actual content as bright as possible, the user should have the feeling that the app consists of two layers:

without-line

To achieve the effect of two layers I additionally had to set the sliding drawer animation. But unfortunately, this places a vertical separator between the drawer and the center view which flickers during the opening / closing animation:

with-line

The same vertical line can be found in the slide and scale and swinging door animation. The behavior is reproducible in the sample app.

Is it possible to remove the vertical line from the sliding animation?

Thanks, David

kcharwood commented 11 years ago

Hmmm. I wonder if that line is coming from the navigation bar itself? I'm not explicitly drawing that line anywhere...

OMezaDev commented 11 years ago

I ran into the same issue, you may be able to solve your issue by changing the following line in MMDrawerController.m -> viewDidLoad

[self.childControllerContainerView setBackgroundColor:[UIColor blackColor]];

to

// Use the dominant color of your left drawer [self.childControllerContainerView setBackgroundColor:[UIColor colorWithRed:.33 green:.33 blue:0.33 alpha:1.0]];

OR you can check if the width of the childControllerContainerView is off somewhere

davidknezic commented 11 years ago

Thanks for the workaround @OMMajestyk. I had some time to experiment with the source code. The artifact I described is not just a line but rather the gap between the left drawer and the center view controller.

So I checked if there is a rounding error in the slideVisualStateBlock or its base, the parallaxVisualStateBlock. But it looks like everything is fine there. Since the horizontal drawer transformation seems to be correct, it has to be the center view controller transformation in the panGesture method. After logging some offset values I discovered that sometimes the center is moved by halves in the following command:

[self.centerContainerView setCenter:CGPointMake(CGRectGetMidX(newFrame), CGRectGetMidY(newFrame))];

By removing the line newFrame = CGRectIntegral(newFrame);, which drops the precise values by rounding them to integer values, the drawer and center view movement offset is accurate and closes the gap between those two.