在 iOS 中,導航欄與搜尋框有時會出現不想要的邊界黑線或陰影。可透過設定背景圖、shadowImage 與 Tint 顏色來移除。
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];[self.textSearchBar setBackgroundImage:[[UIImage alloc] init]];在 Storyboard 中選取搜尋框,於 Attribute Inspector 的 View 區塊,把 Tint 顏色設為 Clear Color。
這些做法通常用於客製化導覽列或搜尋欄,讓畫面更乾淨,也能配合設計稿的視覺需求。