代码片段

1、去掉 NavigationBar 底部的那条黑线

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];


2、iOS7上tableView的分割线左边短了一点

if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
           [_tableView setSeparatorInset:UIEdgeInsetsZero];       
}

3、改变WebView字体大小

代码如下:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '120%'";
    [webView stringByEvaluatingJavaScriptFromString:str];
}


4、改变状态栏字体颜色

1.在info.plist里面添加字段

key----View controller-based status bar appearance
value---NO
 
在appDelegate里面添加代码:
 [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

5、类似iOS导航控制器手势返回的手势,新的api

UIScreenEdgePanGestureRecognizer *screenEdgePanGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgePanGestureRecognizerHanlde:)];
    screenEdgePanGestureRecognizer.edges = UIRectEdgeRight;
    [self.view addGestureRecognizer:screenEdgePanGestureRecognizer];
 
 
- (void)screenEdgePanGestureRecognizerHanlde:(UIScreenEdgePanGestureRecognizer *)screenEdgePanGestureRecognizer {
    NSLog(@"screenEdgePanGestureRecognizer");
}

6、ios7 自定义barbuttonitem 10px的偏移纠正

- (void)addLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem
{
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        // Add a negative spacer on iOS >= 7.0
        negativeSpacer.width = -10;
    } else {
        // Just set the UIBarButtonItem as you would normally
        negativeSpacer.width = 0;
        [self setLeftBarButtonItem:leftBarButtonItem];
    }
    [self setLeftBarButtonItems:[NSArray arrayWithObjects:negativeSpacer, leftBarButtonItem, nil]];
}
 
- (void)addRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem
{
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
 
        negativeSpacer.width = -10;
         
    } else {
        negativeSpacer.width = 0;
    }
    [self setRightBarButtonItems:[NSArray arrayWithObjects:negativeSpacer, rightBarButtonItem, nil]];
}

7、怎么得到私有api

//知道怎么用私有api,要怎么获得
   //要导入#import
   NSString *className = NSStringFromClass([UIView class]);
   //这里是uiview,可以改成自己想要的
   const char *cClassName = [className UTF8String];
   id theClass = objc_getClass(cClassName);
   unsigned int outCount;
   Method *m =  class_copyMethodList(theClass,&outCount;);
   NSLog(@"%d",outCount);
   for (int i = 0; i        SEL a = method_getName(*(m+i));
       NSString *sn = NSStringFromSelector(a);
       NSLog(@"%@",sn);
   }



你可能感兴趣的:(ios开发,iOS)