美文网首页
windowLevel使用实例

windowLevel使用实例

作者: 妮妮世界 | 来源:发表于2017-06-23 18:11 被阅读0次

    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即可

    相关文章

      网友评论

          本文标题:windowLevel使用实例

          本文链接:https://www.haomeiwen.com/subject/rtyccxtx.html