博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 7 Development Tips, Tricks & Hacks
阅读量:6553 次
发布时间:2019-06-24

本文共 3111 字,大约阅读时间需要 10 分钟。

iOS 7 Development Tips, Tricks & Hacks
September 18, 2013
Like with any new iOS version there are a bunch of new tricks and hacks to work out. Here are a few things that weren't immediately obvious to me, it's in no way a complete set, just things that I happened to come across.
If you've got any more then send them to me or and I'll add them here with full credit to you.
Stealing The Blur
Unfortunately Apple didn't give access to their blur effect directly for you to use on your views. Luckily some clever people worked out you could just steal the layer from a UIToolbar.
If you want dark style blur set the toolbar barStyle to UIBarStyleBlack.
Tinting The Navbar
Setting the tint color but it's not tinting? Turns out there's another tint property called 'barTintColor';
   self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
Nil Those Delegates
With iOS 7 you need to nil out your delegates and datasources before your controllers are dealloc'd or you will have a lot of nasty 'message sent to deallocated instance' exceptions.
    - (void)dealloc
    {
        self.tableView.delegate = nil;
        self.tableView.dataSource = nil;
    }
Hide The Status Bar
Don't you love how that transparent status bar floats over content? Yeah me either.
The standard call doesn't do the trick any more:
   [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]
Set the value UIViewControllerBasedStatusBarAppearance to YES in your Info.plist and add this to your controller:
    - (BOOL)prefersStatusBarHidden
    {
        return YES;
    }
Changing The Status Bar Style Per Controller
Set the value UIViewControllerBasedStatusBarAppearance to YES in your Info.plist and override:
 - (UIStatusBarStyle)preferredStatusBarStyle
 {
     return UIStatusBarStyleLightContent;
 }
Custom Back Button And Swipe Back
The only nice way I found to actually completely override the back button is to set the leftBarButtonItem, but then the swipe back gesture breaks. Luckily it's an easy fix when you know how:
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                             initWithImage:img
                                             style:UIBarButtonItemStylePlain
                                             target:self
                                             action:@selector(onBack:)];
    self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
Full Screen Content Transition
When full screen content is shown (say a video is expanded) and the user switches orientation and then closes you will often get an exception. Turns out preferredInterfaceOrientationForPresentation is now a required method.
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    }
Checking For iOS 7
Nothing new here, but useful if you want to perform something only on iOS 7:
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        ...
    } 
My Scroll View Is Moving!
iOS 7 offsets your scroll view 64px (20px for the status bar and 44px for the navigation bar) by default, you can disable this though:
  self.automaticallyAdjustsScrollViewInsets = NO;
CocoaPods Is Breaking in Xcode 5
Check out .

转载于:https://www.cnblogs.com/newBlash/p/4351786.html

你可能感兴趣的文章
Android BitmapFactory.Options
查看>>
前端构建:Less入了个门
查看>>
Hibernate 自动生成数据库表
查看>>
phonegap(cordova) 自己定义插件代码篇(三)----支付宝支付工具整合
查看>>
牛客网Java刷题知识点之构造函数是什么、一般函数和构造函数什么区别呢、构造函数的重载、构造函数的内存图解...
查看>>
博客更名为 健哥的数据花园
查看>>
linux 批量进行:解压缩某一类压缩文件类型的文件
查看>>
ubuntu,CentOS永久修改主机名
查看>>
激活modelsim se 10.4 时运行patch_dll.bat不能生成TXT
查看>>
17秋 软件工程 Alpha 事后诸葛亮会议
查看>>
线性空间
查看>>
Tensflow的targmax函数
查看>>
疑似checkpoint堵塞数据库连接
查看>>
Node.js中针对中文的查找和替换无效的解决方法
查看>>
理解指针的关键
查看>>
如何查看Ubuntu下已安装包版本号
查看>>
MS SQL巡检系列——检查重复索引
查看>>
我的那些年(2)~我毕业了
查看>>
VS2017 配置ImageMagick
查看>>
scrapy 直接在编辑器运行
查看>>