iOS隱藏導覽列底部的線條& UINavigationBar小技巧

來源:互聯網
上載者:User

標籤:透明   rap   text   keyword   bottom   rom   objective   clip   offset   

隱藏導覽列底部的線條

轉載:https://www.jianshu.com/p/aa547432eae0

方法1 (單版面設定)
 [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:[UIImage new]];如果不想影響其他頁面的導航透明度,viewWillDisappear將其設定為nil即可: [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];[self.navigationController.navigationBar setShadowImage:nil];
方法2(全域設定)
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
方法3
self.navigationController.navigationBar.clipsToBounds = YES;
設定導覽列底部線條顏色的代碼:
UINavigationBar *navigationBar = self.navigationController.navigationBar; [navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; //此處使底部線條顏色為紅色[navigationBar setShadowImage:[UIImage imageWithColor:[UIColor redColor]]];
@implementation UIImage (ColorImage)+ (UIImage *)imageWithColor:(UIColor *)color{ CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image;}@end
修複navigationController側滑關閉失效的問題
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self
隱藏返回按鈕後面的文字
 [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)                                                         forBarMetrics:UIBarMetricsDefault];

參考文章:
http://www.jianshu.com/p/f0d3df54baa6
http://stackoverflow.com/questions/19226965/how-to-hide-ios7-uinavigationbar-1px-bottom-line
http://stackoverflow.com/questions/22090314/restore-navigationbar-background-image-after-setting-it-to-uiimage-new



iOS隱藏導覽列底部的線條& UINavigationBar小技巧

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.