首先要先设置一个继承与UIView的一个类,类中包含歌手图片,歌曲,歌手,上一曲和下一曲暂停的view --
PlayView
然后在appdelegate中设置一个属性,属性的类属于
PlayView
在-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(musicChange:) name:@"change" object:nil];
[center addObserver:self selector:@selector(hidden:) name:@"hidden" object:nil];
[center addObserver:self selector:@selector(didHidden:) name:@"didHidden" object:nil];
self.playView = [[PlayView alloc] initWithFrame:CGRectMake(0, self.window.frame.size.height - 60, self.window.frame.size.width, 75)];
self.playView.backgroundColor = [UIColor cyanColor];
self.playView.alpha = 0.5;
self.playView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[self.playView addGestureRecognizer:tap];
}
- (void)tap:(UITapGestureRecognizer *)tap
{
self.play = [PlayViewController sharePlayVC];
[_homeview presentViewController:self.play animated:YES completion:^{
}];
}
- (void)hidden: (NSNotification*)noti
{
self.playView.hidden = NO;
}
- (void)didHidden:(NSNotification *)noti
{
self.playView.hidden = YES;
}
-(void)musicChange:(NSNotification *)noti
{
self.playView.detail = noti.object;
NSLog(@"%@",noti.object);
}
- (void)ReturnButton: (UIButton*)button
{
NSDictionary *notidic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"hidden" object:@"dddd" userInfo:notidic];
[self dismissViewControllerAnimated:YES completion:^{
}];
}