我想让状态栏看起来像Facebook(蓝色)一样黑色,并且当导航栏隐藏在滚动上时应保持相同的稳定性。我需要在swift中以编程方式完成它。 我不想在顶部添加UIView。 可以用AppDelegate完成吗? 我没有使用导航控制器,我正在使用Xibs。
答案 0 :(得分:0)
是的,您可以轻松创建UIView类并将其添加到app delegate,如下所示:
{
...,
"browser": {
"Highcharts": "./vendor/highcharts/highcharts.js",
"HighchartsMore": "./vendor/highcharts/highcharts-more.js",
"HighchartsAdapter": "./vendor/highcharts/standalone-framework.js"
},
"browserify": {
"transform": [
"browserify-shim"
]
},
"browserify-shim": {
"Highcharts": {
"depends": ["HighchartsAdapter:HighchartsAdapter"],
"exports": "Highcharts"
},
"HighchartsMore": {
"depends": ["Highcharts:Highcharts"]
},
"HighchartsAdapter": {
"exports": "HighchartsAdapter"
}
}
现在你可以在app delegate中创建它的框架,如下所示:
//In statusBar.h
@interface statusBar : UIView{
}
//In statusBar.m
@implementation statusBar
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
UIButton *navigationButton = [[UIButton alloc] initWitFrame:CGRectMake(10,10,25,25)];
[self addSubView:navigationButton];
}
return self;
}
现在将每个视图控制器的框架保持在statusBar下面:
//in appDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
statusBar *sb = [[statusBar alloc] initWithFrame:CGRectMake(0,0, self.window.bounds.size.width, 50)];
[self.window addSubview:sb];
}
希望它会有所帮助。