Fork me on GitHub

iphone上自定义状态栏效果的实现

在最新版本的微信,新浪微博等应用中都使用到了状态栏的自定义功能:

效果很酷,实现很简单:

    // 初始化一个状态条级别的window
CGRect frame = CGRectMake(0.0, 0.0, 320.0, 20.0);
UIWindow* statusbarWindow = [[UIWindow alloc] initWithFrame:frame];
[statusbarWindow setBackgroundColor:[UIColor clearColor]];
[statusbarWindow setWindowLevel:UIWindowLevelStatusBar];

// 添加自定义子视图
UIView *customView = [[UIView alloc] initWithFrame:frame];
// ...(各种对视图的定制)
[statusbarWindow addSubview:customView];
[statusbarWindow makeKeyAndVisible];

posted on 2012-02-14 12:41  pengyingh  阅读(268)  评论(0编辑  收藏  举报

导航