一些常见的小技巧用法

1、 隐藏tableViewCell的分割线:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

2、实现右侧的小灰色箭头 只要将cell的accessoryType属性设置为 cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

//关闭tableView选中的动画
[tableView deselectRowAtIndexPath:indexPath animated:NO];

//关闭tableView顶部的cell冒出来的白色空隙
self.automaticallyAdjustsScrollViewInsets = NO

 开启手势返回
 self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;

3、毛玻璃效果(ios8.0以后的版本)

UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    visualEffectView.frame = CGRectMake(0, 0, 320, 180);
    visualEffectView.alpha = 1.0;

4、整个项目iOS手势(滑动)返回
1>、iOS手势(滑动)返回首先在根控制器下 遵守UIGestureRecognizerDelegate协议
2>在跟控制器下写入以下代码,轻松开启手势返回

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    //代理置空,否则会闪退
    if ([self.navigationController       respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
        
    }
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    //开启iOS7的滑动返回效果
    if ([self.navigationController   respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        //只有在二级页面生效
        if ([self.navigationController.viewControllers count] == 2) {
            self.navigationController.interactivePopGestureRecognizer.delegate = self;
        }
    }
}

5、自定义导航栏返回按钮

 UIBarButtonItem *leftBarBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"返回-1"] style:UIBarButtonItemStylePlain target:self action:@selector(goBack)];
    self.navigationItem.leftBarButtonItem = leftBarBtn;

6、导航栏全透明,无黑边

 //    导航栏变为透明
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:0];
    //    让黑线消失的方法
    self.navigationController.navigationBar.shadowImage=[UIImage new];

你可能感兴趣的:(一些常见的小技巧用法)