-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat/#5] 탭바 UI 생성 #7
Open
cinnamonfor6214
wants to merge
1
commit into
main
Choose a base branch
from
feat/#5-create-tabbar-UI
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// | ||
// TabbarView.swift | ||
// dorundorun | ||
// | ||
// Created by 박서현 on 1/20/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct TabbarView: View { | ||
|
||
init() { | ||
let appearance = UITabBarAppearance() | ||
appearance.configureWithOpaqueBackground() | ||
appearance.backgroundColor = UIColor.white // 탭바 배경 설정 | ||
|
||
// 활성화된 아이템 색상 | ||
appearance.stackedLayoutAppearance.selected.iconColor = UIColor(#colorLiteral(red: 0.4748314023, green: 0.3105015755, blue: 0.9763918519, alpha: 1)) | ||
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor(#colorLiteral(red: 0.4748314023, green: 0.3105015755, blue: 0.9763918519, alpha: 1))] | ||
|
||
// 비활성화된 아이템 색상 | ||
appearance.stackedLayoutAppearance.normal.iconColor = UIColor(#colorLiteral(red: 0.7401758432, green: 0.6517201066, blue: 0.98768574, alpha: 1)) | ||
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor(#colorLiteral(red: 0.7401758432, green: 0.6517201066, blue: 0.98768574, alpha: 1))] | ||
|
||
// 탭 아이템 중앙 배치 설정 | ||
appearance.stackedItemPositioning = .centered // 중앙 배치 | ||
appearance.stackedItemSpacing = 4 | ||
|
||
UITabBar.appearance().standardAppearance = appearance | ||
} | ||
|
||
var body: some View { | ||
TabView { | ||
VStack { | ||
Text("홈 화면") | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
|
||
Rectangle() | ||
.frame(height: 4) | ||
.foregroundStyle(Color.gray) | ||
.opacity(0.3) | ||
} | ||
.tabItem { | ||
Label("홈", systemImage: "house") | ||
} | ||
|
||
VStack { | ||
Text("두들런 화면") | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
|
||
Rectangle() | ||
.frame(height: 4) | ||
.foregroundStyle(Color.gray) | ||
.opacity(0.3) | ||
} | ||
.tabItem { | ||
Label("두들런", systemImage: "waveform.path.ecg") | ||
} | ||
|
||
VStack { | ||
Text("마켓 화면") | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
|
||
Rectangle() | ||
.frame(height: 4) | ||
.foregroundStyle(Color.gray) | ||
.opacity(0.3) | ||
} | ||
.tabItem { | ||
Label("마켓", systemImage: "cart") | ||
} | ||
|
||
VStack { | ||
Text("마이페이지 화면") | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
|
||
Rectangle() | ||
.frame(height: 4) | ||
.foregroundStyle(Color.gray) | ||
.opacity(0.3) | ||
} | ||
.tabItem { | ||
Label("마이페이지", systemImage: "person.crop.circle") | ||
} | ||
} | ||
.tint(Color(#colorLiteral(red: 0.4748314023, green: 0.3105015755, blue: 0.9763918519, alpha: 1))) | ||
.onAppear { | ||
UITabBar.appearance().unselectedItemTintColor = UIColor(#colorLiteral(red: 0.7401758432, green: 0.6517201066, blue: 0.98768574, alpha: 1)) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
TabbarView() | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
탭바 개수에 맞춰 중복되는 코드가 늘어나잖아요!
중복되는 코드 보면 텍스트 부분만 바뀌고 있으니까, 따로 뷰로 정의해서 사용하면 더 좋을 것 같습니다!!
조금 더 간결하게 보기도 좋고 유지보수성면에서도 효율적일 것 같아용 😋
++ 왕 저 바본가봐요.. 컨텐츠뷰는 따로 만드는건데 탭바 아이콘이랑 착각햇서요 ㅎ^ ㅎ 다른 작업하실 때 참고해주셔용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오우 피드백 감사합니다!!