Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Stone Preston
42,016 PointsSnapchat style error messages
For anyone interested, I finally found a solution to displaying snapchat style error messages that animate down over the status bar then slide back up:
You need these properties in your header
//header animation properties
@property (strong,nonatomic) UIWindow *dropdown;
@property (strong,nonatomic) UILabel *label;
@property (strong,nonatomic) UIWindow *win;
in your view did load implementation:
//animated header that displays error messages over status bar
self.dropdown = [[UIWindow alloc] initWithFrame:CGRectMake(0, -20, 320, 20)];
self.dropdown.backgroundColor = [UIColor redColor];
self.label = [[UILabel alloc] initWithFrame:self.dropdown.bounds];
self.label.textAlignment = NSTextAlignmentCenter;
self.label.font = [UIFont systemFontOfSize:12];
self.label.backgroundColor = [UIColor clearColor];
[self.dropdown addSubview:self.label];
self.dropdown.windowLevel = UIWindowLevelStatusBar;
[self.dropdown makeKeyAndVisible];
[self.dropdown resignKeyWindow];
The animation method that you need to call whenever you want to display an error
//header animation
-(void)animateHeaderViewWithText:(NSString *) text {
self.label.text = text;
[UIView animateWithDuration:.5 delay:0 options:0 animations:^{
self.dropdown.frame = CGRectMake(0, 0, 320, 20);
}completion:^(BOOL finished) {
[UIView animateWithDuration:.5 delay:2 options:0 animations:^{
self.dropdown.frame = CGRectMake(0, -20, 320, 20);
} completion:^(BOOL finished) {
//animation finished!!!
}];
;
}];
}
This is the only thing I have found so far that works, and you dont have to mess with showing/hiding/replacing the status bar.
big thanks to rdelmar on stackoverflow, you can view the original thread here
2 Answers

Rashii Henry
16,433 Pointshmm, did you create a new class? or did you add them to a class thats already created?

Ben Jakuben
Treehouse TeacherCool, and thanks for sharing! Can you link to a screenshot for us to see how it looks?
Stone Preston
42,016 PointsStone Preston
42,016 PointsThis is in a view controller. You could create your own class Though