NavigationView에서 BackButton을 그냥 주황색 화살표 하나만 남기고 싶었는데.. 그 정보를 찾는게 왜이렇게 어렵지??
import SwiftUI
@main
struct DiaryApp: App {
init() {
let image = UIImage(systemName: "arrow.left")
UINavigationBar.appearance().backIndicatorImage = image
UINavigationBar.appearance().backIndicatorTransitionMaskImage = image
//이건 작동 안하는 듯...
// UINavigationBar.appearance().barTintColor = .orange
// 네비게이션 타이틀 텍스트 색상 검정색 적용..
UIBarButtonItem.appearance().setTitleTextAttributes([
NSAttributedString.Key.foregroundColor: UIColor.black
], for: .normal)
}
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(DiaryFetcher())
.environmentObject(observed())
}
}
}
- 앱 루트에서 초기화시 네비게이션바 설정을 해준다.
- setTitleTextAttributes 로 색상을 적용해주면, NavigationView에서 title 적용시 title색상, 디폴트일 경우 백버튼의 Back 텍스트에도 적용 된다.
tint 색상 적용(화살표 색상 적용)
NavigationView {
...
}
.tint(.orange)
'IOS' 카테고리의 다른 글
Swift 에러 핸들링 (try, catch, throw, throws, do) (0) | 2022.12.28 |
---|---|
UIKit 커스텀 애니메이션 (0) | 2022.12.20 |
SwiftUI 에서 UIKit 사용하기 (0) | 2022.11.01 |
NSCollectionLayoutDimension 알아보기 (0) | 2022.10.15 |
UIKit UIView 의 Frame 과 Bounds (0) | 2022.10.10 |