在io7中,视图顶部的状态栏是一场噩梦.我真的设法让它工作,所以它将被放置在视图上方.我这样做:
- (void)viewDidLoad
{
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
self.view.backgroundColor=[UIColor colorWithRed:(152/255.0) green:(204/255.0) blue:(51/255.0) alpha:1] ;
CGRect frame = self.topNav.frame; frame.origin.y = 20;
self.topNav.frame = frame;
}
....
}
Run Code Online (Sandbox Code Playgroud)
现在我的状态栏位于我的导航栏上方.
但是当谈到调用的UIImagePickerController东西是不同的时.上面的代码没有任何效果.我试着这样做:
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect frame = self.imagePickerController.frame; frame.origin.y = 20;
self.imagePickerController.frame = frame;
}
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
self.imagePickerController = imagePickerController;
self.imagePickerController.allowsEditing=YES;
....
} …Run Code Online (Sandbox Code Playgroud)