ios7 tweak

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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值