代码改变世界

转:iphone遮盖系统栏,实现自定义效果的状态栏

2011-12-24 16:12  张智清  阅读(463)  评论(0编辑  收藏  举报

下面的代码演示了创建一个小图标从时间的左侧移动到时间右侧的简单效果,关于自定义状态栏可以参考。

CGRect frame = {{0,0},{320,20}};
UIWindow *wd = [[UIWindow alloc] initWithFrame:frame];
[wd setBackgroundColor:[UIColor clearColor]];
[wd setWindowLevel:UIWindowLevelStatusBar];
frame = CGRectMake(100,0,30,20);
UIImageView *imgv = [[UIImageView alloc] initWithFrame:frame];
[imgv setContentMode:UIViewContentModeCenter];
[imgv setImage:[UIImage imageNamed:@"0103.png"]];
[wd addSubview:imgv];
[wd makeKeyAndVisible];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
frame.origin.x += 150;
[imgv setFrame:frame];
[UIView commitAnimations];
[imgv release];