[英]How can i show a message pop up like Play Music app
I want to add bar like Play Music app of google shows in the their application. 我想在其应用程序中添加类似Google show的Play音乐应用程序的栏。 I want to use that same animation effect as they are doing. 我想使用与他们相同的动画效果。 So Can any one guide me that is there any open source code to add this functionality in the app or i need to code it all manually, any guide will be helpful, I search net but i did not found any. 因此,有没有人可以指导我是否有任何开源代码可以在应用程序中添加此功能,或者我需要手动对其全部进行编码,所以任何指南都会有所帮助,我在网上搜索但没有找到任何内容。
@interface ViewController ()
@property (nonatomic, weak) UILabel *popupLabel;
@end
@implementation ViewController
- (UILabel *)popupLabel
{
if( !_popupLabel ) {
CGFloat height = 44.0;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,
self.view.bounds.size.height - height,
self.view.bounds.size.width,
height)];
label.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.alpha = 0.0;
[self.view addSubview:label];
_popupLabel = label;
}
[self.view bringSubviewToFront:_popupLabel];
return _popupLabel;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self performSelector:@selector(showWithMessage:) withObject:@"1 song added to playlist" afterDelay:2.0];
}
- (void)showWithMessage:(NSString *)message
{
self.popupLabel.text = message;
[UIView animateWithDuration:1.0 animations:^{
self.popupLabel.alpha = 1.0;
}];
}
- (void)hide
{
[UIView animateWithDuration:1.0 animations:^{
self.popupLabel.alpha = 0.0;
}];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.