您的位置:首页 > 移动开发 > IOS开发

iOS 开发小技巧

2016-04-21 11:38 501 查看
1.隐藏多余的tableView的cell分割线
self.tableView.tableFooterView= [[UIView alloc]init];


2.取消系统自带的返回字样
[[UIBarButtonItem appearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];


3.滑动时隐藏navigation
self.navigationController.hidesBarsOnSwipe=YES;


4.页面跳转是隐藏tabBar
TwoViewController *twoVC = [[TwoViewController alloc] init];

twoVC.hidesBottomBarWhenPushed =YES;


5.ScrollView不能滑到顶
self.automaticallyAdjustsScrollViewInsets=NO;


6.按钮点击发光效果
button.showsTouchWhenHighlighted =YES;


7.长按手势只执行一次
if(sender.state == UIGestureRecognizerState)


8.隐藏状态栏
- (BOOL)prefersStatusBarHidden

{

returnYES;

}


9.在使用view的缩放的时候,layer.border.width随着view的放大,会出现锯齿化的问题。
self.layer.allowsEdgeAntialiasing = YES;


10、在自定义返回按钮的时候,侧滑手势返回往往默认失效了,怎么让侧滑有效呢 UIButton *btn =[UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"返回" forState:UIControlStateNormal];

[btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];

btn.frame=CGRectMake(0, 0, 60, 40);

[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

UIBarButtonItem  *item =[[UIBarButtonItem alloc]initWithCustomView:btn];

self.navigationItem.leftBarButtonItem=item;


添加下面这一句代码即可
self.navigationController.interactivePopGestureRecognizer.delegate=(id)self;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: