如何显示播放音乐应用程序的消息

时间:2013-11-28 07:51:21

标签: ios iphone objective-c cocoa-touch uiview

我想在他们的应用程序中添加Google Play等Play Play应用程序栏。我想使用与他们相同的动画效果。所以任何人都可以指导我,有任何开源代码在应用程序中添加此功能或我需要手动编码,任何指南将有所帮助,我搜索网但我没有找到任何。

enter image description here

1 个答案:

答案 0 :(得分:1)

@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;
    }];
}