原文連結:點選這裡
1、navigationBar變為純透明
//第一種方法
//導航欄純透明
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//去掉導航欄底部的黑線
self.navigationBar.shadowImage = [UIImage new];
//第二種方法
[[self.navigationBar subviews] objectAtIndex:].alpha = ;
tabBar同理
[self.tabBar setBackgroundImage:[UIImage new]];
self.tabBar.shadowImage = [UIImage new];
2、navigationBar根據滑動距離的漸變色實作
//第一種
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offsetToShow = ;//滑動多少就完全顯示
CGFloat alpha = - (offsetToShow - scrollView.contentOffset.y) / offsetToShow;
[[self.navigationController.navigationBar subviews] objectAtIndex:].alpha = alpha;
}
//第二種
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offsetToShow = ;
CGFloat alpha = - (offsetToShow - scrollView.contentOffset.y) / offsetToShow;
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
[self.navigationController.navigationBar setBackgroundImage:[self imageWithColor:[[UIColor orangeColor]colorWithAlphaComponent:alpha]] forBarMetrics:UIBarMetricsDefault];
}
3、生成一張純色的圖檔
- (UIImage *)imageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(f, f, f, f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
4、iOS 開發中一些相關的路徑
模拟器的位置:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
文檔安裝位置:
/Applications/Xcode.app/Contents/Developer/Documentation/DocSets
插件儲存路徑:
~/Library/ApplicationSupport/Developer/Shared/Xcode/Plug-ins
自定義代碼段的儲存路徑:
~/Library/Developer/Xcode/UserData/CodeSnippets/
如果找不到CodeSnippets檔案夾,可以自己建立一個CodeSnippets檔案夾。
描述檔案路徑
~/Library/MobileDevice/Provisioning Profiles