ios7 tweak

来源:互联网 发布:ubuntu 13.04安装失败 编辑:程序博客网 时间:2024/06/10 16:18
1.[UIView performWithoutAnimation:] 替代

[UIView setAnimationsEnabled:NO];

code here...

[UIView setAnimationsEnabled:YES];


2.实现tableView:estimatedHeightForRowAtIndexPath:代理函数或者设置estimatedRowHeight属性值,提供一个预估高度值,

对于可变高度的cell的表格视图可改进性能


3.UISearchDisplayController新增属性:displaysSearchBarInNavigationBar,可让搜索控件显示在导航栏,但不可与showsScopeBar同时设置为YES,即显示在导航栏的搜索控件不能有范围选择栏


4.UIResponder新增属性keyCommands,相应的有个新增类UIKeyCommand,可用于捕获蓝牙键盘的按键事件,例:

- (NSArray *)keyCommands {    return @[[UIKeyCommand keyCommandWithInput:@"f"                                 modifierFlags:UIKeyModifierCommand                                          action:@selector(searchKeyPressed:)]];}- (void)searchKeyPressed:(UIKeyCommand *)keyCommand {    // Respond to the event}

5.新增UIInputView,可用来自定义键盘或者扩展默认键盘


6.CTTelephonyNetworkInfo:用来判断手机当前的网络类型,是edge还是LTE或其他,currentRadioAccessTechnology的值可为:

CTRadioAccessTechnologyCDMA1x

CTRadioAccessTechnologyCDMAEVDORev0

CTRadioAccessTechnologyCDMAEVDORevA

CTRadioAccessTechnologyCDMAEVDORevB

CTRadioAccessTechnologyEdge

CTRadioAccessTechnologyGPRS

CTRadioAccessTechnologyHSDPA

CTRadioAccessTechnologyHSUPA

CTRadioAccessTechnologyLTE

CTRadioAccessTechnologyWCDMA

CTRadioAccessTechnologyeHRPD

CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);[NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification                                                 object:nil                                                  queue:nil                                             usingBlock:^(NSNotification *note) {    NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);}];


7.下载字体:CTFontDescriptorMatchFontDescriptorsWithProgressHandler

获取可下载字体:

CFDictionary *descriptorOptions = @{(id)kCTFontDownloadableAttribute : @YES};CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)descriptorOptions);CFArrayRef fontDescriptors = CTFontDescriptorCreateMatchingFontDescriptors(descriptor, NULL);


Tint images with UIImage.renderingMode

UIImage *img = [UIImage imageNamed:@"myimage"];img = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

UIImageRenderingMode Cheat Sheet


新增UIApplicationUserDidTakeScreenshotNotification通知,当用户截屏时触发


UIScreenEdgePanGestureRecognizer

UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleScreenEdgeRecognizer:)];recognizer.edges = UIRectEdgeLeft;[self.view addGestureRecognizer:recognizer];


keyboardDismissMode:scrollView滚动时隐藏键盘

self.scrollView.keyboardDismissMode =UIScrollViewKeyboardDismissModeOnDrag;//刚拖动scrollView就隐藏键盘

self.scrollView.keyboardDismissMode =UIScrollViewKeyboardDismissModeInteractive;//从键盘上面点(scrollView未遮挡部分)向下滑动,键盘会跟着滑动;又往上滑动键盘也会跟着向上滑动

UIScrollViewKeyboardDismissModeNone//默认值,没有任何影响



参考网址:http://www.objc.io/issue-5/iOS7-hidden-gems-and-workarounds.html

原创粉丝点击