Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message background cover status bar on iOS 7 #16

Closed
cytryn opened this issue Dec 14, 2013 · 19 comments
Closed

Message background cover status bar on iOS 7 #16

cytryn opened this issue Dec 14, 2013 · 19 comments

Comments

@cytryn
Copy link

cytryn commented Dec 14, 2013

It would be more awesome if the message background covers the status bar on iOS 7

This way on dont depend on app design for the warning box to make sense.

@ChrisGrant
Copy link
Contributor

+1

1 similar comment
@mrgrauel
Copy link

+1

@mergesort
Copy link

Well since everyone else is doing it, +1

@terryworona
Copy link
Owner

So, the consensus is to have the message view cover the status bar as it drops down? Can you elaborate on what you mean by "This way on dont depend on app design for the warning box to make sense." ?

@mergesort
Copy link

I dig the message bar covering the status bar. From a really quick look at the code, I think the quick way to achieve this effect is to remove self.messageBarOffset at line 196:

[UIView animateWithDuration:kTWMessageBarManagerAnimationDuration animations:^{
    messageView.frame.origin.y + [messageView height], [messageView width], [messageView height])]; // slide down 
}];

And to hide the status bar during the duration of the animations.

@mergesort
Copy link

Alternatively, if you still want the status bar to be visible, you could make the message bar 20 pixels taller, while setting the self.messageBarOffset to 0, and shifting all of the content inside down 20 pixels to account for the status bar's height.

@mrgrauel
Copy link

I'd suggest to add a method in the interface to keep the old behavior but set the cover as default, cause that's how iOS 7 supports to work.

@cytryn
Copy link
Author

cytryn commented Dec 16, 2013

@terryworona What I meant is that covering the status bar with the same color wont break the design because you can have for example a navigation bar in one color and the view background in another color.

Then the message would appear in a third completely different color making it appear ugly as hell...

@kurtbradd
Copy link

@terryworona I have opened a pull request for this requested feature.

@terryworona
Copy link
Owner

Pushed a few updates related to this. However, I can't seem to get the message views to cover the status bar entirely.

We could hide the status bar, but that requires setting a project plist value (see: http://stackoverflow.com/questions/18059703/cannot-hide-status-bar-in-ios7).

To see what I'm talking about, uncomment line 281 of the TWMessageBarManager (v1.3.1) & notice how the view appears underneath the status bar.

Any ideas?

@Amnell
Copy link

Amnell commented Jan 15, 2014

Is it really necessary to display the message on top of the StatusBar? To be able to do that the developers may have to interfer with UIViewControllerBasedStatusBarAppearance or -prefersStatusBarHidden. And it may result in strange behaviour in other 3rd party components (or when displaying a MFMailComposeViewController or an UIImagePickerController )

Instead of showing the message on top of the Statusbar i like what @terryworona suggested as an alternative; To show the message underneath the Statusbar. I've done some testing and i like the look: http://f.cl.ly/items/1R141v1p1R0N2S261h2Z/iOS%20Simulator%20Screen%20shot%2015%20jan%202014%2010.25.12.png

What do you guys think?

@cytryn
Copy link
Author

cytryn commented Jan 15, 2014

@Amnell that is what we are all talking about. Keeping the status bar visible or not is really not an issue.
The important thing here is to have the status bar have the same background as the message.

@terryworona
Copy link
Owner

Ah ok, now I understand. Screenshots help!

So for iO7, set the message view's origin to be y-statusBar.height and extend it's height+=statusBar.height.

Sound about right?

@paradoxally
Copy link

Well, @Amnell, Tapbots with Tweetbot 3 implement a very similar looking control to this one (even has a message queue as well), but they hide the status bar when showing the various messages (either blue for info or red for warning). The status bar appears and disappears naturally after each message. If there is a queue, the status bar disappears on the first message and only reappears when the last message disappears.

I've been able to implement a way to hide the status bar when showing just one message and then animate it back in when it disappears or the user taps on a button, but as soon as multiple messages start coming in, my code no longer is optimal.

Basically, my implementation is simple (you can implement this in TWMesssageBarDemoController.m). Create a boolean:

@property (nonatomic) BOOL hideBar;

And then to implement the hiding and unhiding, for example:

- (void)errorButtonPressed:(id)sender
{
    [self performSelector:@selector(hide) withObject:self afterDelay:0];
        [[TWMessageBarManager sharedInstance] showMessageWithTitle:kStringMessageBarErrorTitle
                                                   description:kStringMessageBarErrorMessage
                                                          type:TWMessageBarMessageTypeError
                                                           callback:^{
                                                               [self unhide];
                                                           }];
    // the delay is hardcoded just as an example, maybe expose this internal value to the developer?
    [self performSelector:@selector(unhide) withObject:self afterDelay:3.25]; }

- (void)unhide {
        [UIView animateWithDuration:0.1 animations:^{
            self.hideBar = NO;
            [self setNeedsStatusBarAppearanceUpdate];
        }];

}

- (void)hide {
    [UIView animateWithDuration:0.1 animations:^{
        self.hideBar = YES;
        [self setNeedsStatusBarAppearanceUpdate];
    }];

}

@Amnell
Copy link

Amnell commented Jan 16, 2014

@paradoxally The problem with that solution is that it will be harder to implement TWMessageBarManager as UIViewControllerBasedStatusBarAppearance cant be set to NO and the implementing ViewController needs a fair bit of code.

Ideally TWMessageBarManager should be a drop-in module that doesn't force the developer to change a bunch of stuff in ther application or ViewControllers.

@cytryn
Copy link
Author

cytryn commented Jan 21, 2014

@terryworona that would be great!

@Amnell
Copy link

Amnell commented Jan 25, 2014

I've created pull request #22 for the behavior I described earlier in this thread.

terryworona pushed a commit that referenced this issue Feb 6, 2014
@terryworona
Copy link
Owner

Hey everyone, fixed this issue in commit: f4400e8

I kept it simple:

If >= iOS 7 -> extend the message view's height by the status bar height and set it's y offset to be the status bar's max y-position. As well, push the content of the message view down by the status bar height.

Hope this helps.

@terryworona
Copy link
Owner

Fixed in v1.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants