iOS 随笔

1.设置导航栏透明 Item 不透明 同时修改适应的title文字颜色

[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics: UIBarMetricsDefault];

[self.navigationBar setShadowImage:[UIImage new]];

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};

2.view添加渐变色

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = colorView.bounds;
gradient.colors = [NSArrayarrayWithObjects: 
(id)[UIColorcolorWithRed:0green:143/255.0blue:234/255.0alpha:1.0].CGColor,  
(id)[UIColorcolorWithRed:0green:173/255.0blue:234/255.0alpha:1.0].CGColor, 
(id)[UIColorwhiteColor].CGColor, nil];

[self.view.layer addSublayer: gradient];

3.时间显示上午或者下午

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

formatter.AMSymbol = @"AM";

formatter.PMSymbol = @"PM";

formatter.dateFormat = @"hh:mm aaa";

NSString*dateStr = [formatter stringFromDate: date];

4.scroll delegate 判断手指移动变化

    CGPoint point =  [scrollView.panGestureRecognizer  translationInView: self.view];
判断point变化 判断手势方向

5.tableview 刷新周期

CATransaction.begin()

 CATransaction.setCompletionBlock {

    self.tableView.reloadData()

}

 self.tableView.beginUpdates()

 self.tableView.deleteRows(at: [(NSIndexPath(row: idx, section: 0) as IndexPath)], with: .left)

 self.tableView.endUpdates()

 CATransaction.commit()

6.终端输入 Xceode 显示编译时长

defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES

你可能感兴趣的:(iOS 随笔)