iOS7开发技巧
来源:互联网 发布:淘宝跟客服聊天 编辑:程序博客网 时间:2024/06/05 20:55
和任何新的iOS版本一样,有着一堆堆的新技巧和修改需要处理.有些我并不会立即遇到,所以这篇文章并不是一套完整技巧汇总.只是分享一些我碰巧遇到的问题.
如果你有任何更多的发现,可以发Twitter或者email给我.我将免费一起汇入这篇文章.
Stealing The Blur
不幸的是,苹果并没有给你在views上直接使用模糊效果的方法.不过有一些聪明人采取修改UIToolbar的layer来做到iOS模糊. iOS-blur
你如果是想使用黑色风格的模糊,设置这个toolbar的barstyle为UIBarStyleBlack.
Tinting The Navbar
设置导航条的颜色,但是没有效果?原来还有另外一个设置色调的属性叫:'barTintColor'.
1 self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
Nil Those Delegates
在 iOS7 上你需要在你controllers销毁之前,将 delegates and datasources 设置成 nil.否则你会有很多让人讨厌的' 'message sent to deallocated instance''异常
1 - (void)dealloc2 {3 self.tableView.delegate = nil;4 self.tableView.dataSource = nil;5 }
Hide The Status Bar
你是不是不喜欢透明的状态栏浮在内容的上面?是的,我也不喜欢.
标准的说法是不要在做任何诡计.
1 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]
在Info.plist里面设置UIViewControllerBasedStatusBarAppearance 为 YES,然后添加这个到你的controller里面
1 - (BOOL)prefersStatusBarHidden2 {3 return YES;4 }
Changing The Status Bar Style Per Controller
在Info.plist里面设置UIViewControllerBasedStatusBarAppearance 为 YES,然后覆写:
1 - (UIStatusBarStyle)preferredStatusBarStyle2 {3 return UIStatusBarStyleLightContent;4 }
Custom Back Button And Swipe Back
我发现唯一好的办法重写back按钮就是设置leftBarButtonItem,但是这样swipe 的手势又有问题了.幸运的是有一个非常简单的办法来修复
1 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]2 initWithImage:img3 style:UIBarButtonItemStylePlain4 target:self5 action:@selector(onBack:)];6 self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
Full Screen Content Transition
当内容全屏展示的时候(比如一个展开的视频),并且这时用户旋转方向,然后再关闭.你常常就会得到一个异常.这个情况就需要拿出preferredInterfaceOrientationForPresentation方法了.
1 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation2 {3 return UIInterfaceOrientationPortrait;4 }
Checking For iOS 7
这不是什么新鲜方法.但是如果你只想在iOS7下执行可以这样写
1 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {2 ...3 }
判断iOS7以下的话可以这样:
1 NSUInteger DeviceSystemMajorVersion(); 2 3 NSUInteger DeviceSystemMajorVersion() { 4 5 static NSUInteger _deviceSystemMajorVersion = -1; 6 7 static dispatch_once_t onceToken; 8 9 dispatch_once(&onceToken, ^{10 _deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];11 });12 return _deviceSystemMajorVersion;13 }14 15 #define IOS_VERSION_LOW_7 (DeviceSystemMajorVersion() < 7)
My Scroll View Is Moving!
iOS7 默认偏移你的scrollview 64px(20px的状态栏,44px的导航栏)
不过你依然可以禁用这个
1 self.automaticallyAdjustsScrollViewInsets = NO;
- iOS7开发技巧
- iOS开发技巧-iOS7 iOS6 StatusBar
- APP IOS6 适配iOS7开发技巧
- IOS7技巧
- IOS7技巧
- ios7开发的一些技巧 textfiled tableview重用 idfa 证书
- iOS7中的小技巧
- iOS开发小技巧总结1(iOS7 企业证书部署等问题)
- iOS开发-UITextView的用法及技巧(ios7下光标bug解决方案)
- IOS7开发~错误收集
- IOS7开发~UIKit Dynamics
- IOS7 游戏开发支持
- IOS7开发~TextKit学习
- IOS7开发~NSAttributedString
- IOS7开发~API变化
- IOS7开发~Images.xcassets
- IOS7 开发注意事项
- IOS7开发~UDID解决方法
- 最大堆(max-heap)和最小堆(min-heap)
- startup命令显示的结果可以看出数据库启动的三个阶段
- IO 缓存<-----字节<-----字符
- 润乾平台 - 用已有的xml与json文件为数据集设置宏和参数
- Java 代码功能片段(待续。。。)
- iOS7开发技巧
- php-魔术方法
- form内只有一个输入框时,按回车不让自动提交的解决方案
- 宗教信仰(并查集)
- svn命令
- write的奥秘
- 控制Button字体颜色变化
- System.Configuration.ConfigurationErrorsException: 项“ ”已添加。
- 备份文件的python脚本