1.UIWindow的windowLevel有三个取值
UIWindowLevelAlert:值为2000,同对话框的层级
UIWindowLevelStatusBar:值为1000,是状态栏的层级
UIWindowLevelNormal::值为0.000000,是默认值,
注意:值越大显示的越靠上。
2.懒加载
- (UILabel *)topLable
{
if(_topLable == NULL)
{
_topLable = [[UILabel alloc] initWithFrame:CGRectMake(0, -60, LYWIDTH, 60)];
_topLable.backgroundColor = [UIColor grayColor];
_topLable.textColor = [UIColor blackColor];
_topLable.font = [UIFont fontWithName:LYCOMMON_FONT_NAME size:LYWeatherName_textF];
_topLable.textAlignment = NSTextAlignmentCenter;
}
return _topLable;
}
3.实现从状态栏之上划入一个视图
self.window.windowLevel = UIWindowLevelAlert;
[self.window addSubview:self.topLable];
self.topLable.text = @"接收本地通知啦";
[UIView animateWithDuration:1.0 animations:^{
self.topLable.frame = CGRectMake(0, 0, LYWIDTH, 60);
} completion:^(BOOL finished)
{
[UIView animateWithDuration:1.0 delay:2.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.topLable.frame = CGRectMake(0, -60, LYWIDTH, 60);
} completion:^(BOOL finished) {
self.window.windowLevel = UIWindowLevelNormal;
}];
}];
4.实现从状态栏之上划入一个视图
window的windowLevel改为UIWindowLevelNormal即可