简体   繁体   English

如何显示弹出消息,例如“播放音乐”应用

[英]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.

相关问题 如何编写应用程序中的音乐以在特定时间播放? - How can I program music from an app to play on a specific time? 如何更改应用内购买的弹出消息? - How to change pop up message for in app purchase? 我可以让我的应用程序播放的库项目显示为最近在音乐应用程序中播放的内容吗? - can I have library items my app plays show up as recently played in the Music app? 我可以选择iTunes中的音乐/视频并在我的应用程序中播放吗? - Can I select music/video that is in iTunes and play in my app? 如何使我的IOS应用永久在后台播放音乐? - How to I make my IOS app play music in the background forever? 如何像Safari / iBooks /音乐等一样设置应用程序的背景? - How can I set background of my app just like Safari / iBooks / Music etc? 当按下音量调高/调低按钮时,如何隐藏弹出的消息 - how can I hide the message thats pop out when volume up/down button pressed 如何在iOS上的VLC中播放音乐文件的URL? - How can I make URLs to music files play in VLC on iOS? 如何使iOS设备以编程方式播放音乐? - How can I make an iOS device play music programatically? 如何使用 UIWebView 或 WKWebView 在后台连续播放音乐 - How can I play music successively in the background with UIWebView or WKWebView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM