Last active
August 29, 2015 14:03
-
-
Save sanketfirodiya/ebad56de5b49a0cbfc70 to your computer and use it in GitHub Desktop.
Fake push notification banner for in-app notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)showFakePushNotificationAnimation:(NSNotification *)notification { | |
if (notification) { | |
NSString *message = [NSString stringWithFormat:@"%@", [[[notification object] objectForKey:@"aps"] objectForKey:@"alert"]]; | |
UIToolbar *newmessageBannerView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -BANNER_HEIGHT, self.view.frame.size.width, BANNER_HEIGHT)]; | |
newmessageBannerView.translucent = YES; | |
newmessageBannerView.barTintColor = [UIColor colorWithWhite:0.074 alpha:0.550]; | |
UILabel *bannerLabel = [[UILabel alloc] initWithFrame:CGRectMake(44.0, 10.0, 320.0, 22.0)]; | |
bannerLabel.textAlignment = NSTextAlignmentLeft; | |
bannerLabel.textColor = [UIColor whiteColor]; | |
bannerLabel.font = [UIFont systemFontOfSize:17.0]; | |
bannerLabel.text = message; | |
[newmessageBannerView addSubview:bannerLabel]; | |
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 13.0, 16.0, 16.0)]; | |
imageView.image = [UIImage imageNamed:@"AppIcon_24"]; | |
[newmessageBannerView addSubview:imageView]; | |
[self.view addSubview:newmessageBannerView]; | |
[UIView animateWithDuration:0.25 delay:0.5 options:UIViewAnimationOptionCurveLinear | |
animations:^{ | |
newmessageBannerView.frame = CGRectMake(0, 0, self.view.frame.size.width, BANNER_HEIGHT); | |
} | |
completion:^(BOOL finished) { | |
[UIView animateWithDuration:0.25 delay:3.0 options:UIViewAnimationOptionCurveLinear | |
animations:^{ | |
newmessageBannerView.frame = CGRectMake(0, -BANNER_HEIGHT, self.view.frame.size.width, BANNER_HEIGHT); | |
}completion:^(BOOL finished) { | |
[newmessageBannerView removeFromSuperview]; | |
}]; | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment