2013-10-04 15 views
5

iOS 6 cái nhìn ...Làm thế nào để thiết lập màu Tình trạng thanh nền iOS 7

enter image description here

giống như cách tôi muốn hiển thị trên thanh trạng thái trong iOS 7 như

này

thấy enter image description here

nhưng sản lượng thực tế của tôi (Chồng chéo)

tôi đã cố gắng sau Logic

open your info.plist and set "View controller-based status bar appearance" = NO 

nó không làm việc trong mã của tôi ,,,

+0

@ swt- của họ là rất nhiều câu hỏi trên SO, u đã tìm kiếm –

Trả lời

17

Bạn cần phải làm 2 việc. Đầu tiên là mở của bạn info.plist và thiết lập "View controller-based status bar appearance" = NO

Và thứ hai là thêm dòng này để application:didFinishLaunchingWithOptions

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) 
{ 
    self.window.clipsToBounds = YES; 
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];  

    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) 
    { 
     self.window.frame = CGRectMake(20, 0,self.window.frame.size.width-20,self.window.frame.size.height); 
     self.window.bounds = CGRectMake(20, 0, self.window.frame.size.width, self.window.frame.size.height); 
    } else 
    { 
     self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20); 
     self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height); 
    } 
} 
+0

ứng dụng của tôi chạy ở chế độ ngang. nhưng mã của bạn xuất hiện thanh màu đen bên phải và bên trái – SWT

+0

Cập nhật câu trả lời để hỗ trợ cả hai hướng. – Stanislav

+0

nhưng hoạt động tốt ... nhưng khi tôi xoay màn hình không thay đổi dựa trên hướng màn hình – SWT

9

Đọc bài viết này: http://www.appcoda.com/customize-navigation-status-bar-ios-7/

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 

[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)]; 
+0

Liên kết tuyệt vời cho những người đặt hình ảnh trên UINavigationBar của họ. – capikaw

+1

Đáng buồn là không làm được gì nhiều cho ứng dụng iPad của tôi. Liên kết tốt mặc dù – cynistersix

+0

Vì một số lý do, điều này không hiệu quả đối với tôi, bảng phân cảnh, ios7. Đã thêm dòng đó vào AppDelegate didFinishLaunching – Fraggle

0

Di chuyển khung hình của bạn 20 pixel xuống. Bạn có thể thử viết những dòng này trong viewWillAppear hoặc

CGRect frame = self.view.frame; 
frame.origin.y = 20; 

if (self.view.frame.size.height == 1024 || self.view.frame.size.height == 768) 
{ 
    frame.size.height -= 20; 
} 
self.view.frame = frame; 

Bây giờ thiết lập màu DidAppear

nền của cửa sổ sang màu đen trong applicationDidFinishLaunching và thiết lập font chữ statusbar có màu trắng (StatusBarContentLight)

Hãy nhớ những gì tôi đang thấy không phải là giải pháp hoàn hảo nhưng một bản sửa lỗi sẽ hoạt động tốt. Cũng sử dụng cùng một mã khi ứng dụng thay đổi hướng của nó (ShouldAutorotate)

Các vấn đề liên quan