Skip to content

Commit

Permalink
#82 Feat: 탭바 재구현 (아이콘 제외)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlguszoo committed Sep 29, 2024
1 parent 2016699 commit 22d4c43
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 21 deletions.
12 changes: 4 additions & 8 deletions Drink-EG/Drink-EG.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
16C19ADE2C73AF6000E93FD0 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16C19ADD2C73AF6000E93FD0 /* UserDefaults.swift */; };
16C19AE12C74423300E93FD0 /* SwiftyToaster in Frameworks */ = {isa = PBXBuildFile; productRef = 16C19AE02C74423300E93FD0 /* SwiftyToaster */; };
16C19AE62C74987600E93FD0 /* YouTubeiOSPlayerHelper in Frameworks */ = {isa = PBXBuildFile; productRef = 16C19AE52C74987600E93FD0 /* YouTubeiOSPlayerHelper */; };
16C19B0B2C7DA80C00E93FD0 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 16C19B0A2C7DA80C00E93FD0 /* Realm */; };
16C19B0D2C7DA80C00E93FD0 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 16C19B0C2C7DA80C00E93FD0 /* RealmSwift */; };
16C19B102C7DB73200E93FD0 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = 16C19B0F2C7DB73200E93FD0 /* Then */; };
16C19B162C7DB88100E93FD0 /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16C19B152C7DB88100E93FD0 /* Note.swift */; };
Expand Down Expand Up @@ -125,6 +124,7 @@
1FBD19532C6CFABB005C16A8 /* WineShopListCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FBD19522C6CFABB005C16A8 /* WineShopListCollectionViewCell.swift */; };
1FBD19552C6D2BF7005C16A8 /* ReviewListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FBD19542C6D2BF7005C16A8 /* ReviewListViewController.swift */; };
1FBD19572C6DDBAB005C16A8 /* ReviewListCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FBD19562C6DDBAB005C16A8 /* ReviewListCollectionViewCell.swift */; };
1FC522272CA91ED000EC0635 /* TabBarShadow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC522262CA91ED000EC0635 /* TabBarShadow.swift */; };
5E22192D2C69D592005849FB /* Pretendard-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 5E2219242C69D592005849FB /* Pretendard-Bold.otf */; };
5E22192E2C69D592005849FB /* Pretendard-Black.otf in Resources */ = {isa = PBXBuildFile; fileRef = 5E2219252C69D592005849FB /* Pretendard-Black.otf */; };
5E22192F2C69D592005849FB /* Pretendard-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 5E2219262C69D592005849FB /* Pretendard-Regular.otf */; };
Expand Down Expand Up @@ -293,6 +293,7 @@
1FBD19522C6CFABB005C16A8 /* WineShopListCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WineShopListCollectionViewCell.swift; sourceTree = "<group>"; };
1FBD19542C6D2BF7005C16A8 /* ReviewListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewListViewController.swift; sourceTree = "<group>"; };
1FBD19562C6DDBAB005C16A8 /* ReviewListCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewListCollectionViewCell.swift; sourceTree = "<group>"; };
1FC522262CA91ED000EC0635 /* TabBarShadow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarShadow.swift; sourceTree = "<group>"; };
5E2219242C69D592005849FB /* Pretendard-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Bold.otf"; sourceTree = "<group>"; };
5E2219252C69D592005849FB /* Pretendard-Black.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Black.otf"; sourceTree = "<group>"; };
5E2219262C69D592005849FB /* Pretendard-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Regular.otf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -333,7 +334,6 @@
buildActionMask = 2147483647;
files = (
16C19B0D2C7DA80C00E93FD0 /* RealmSwift in Frameworks */,
16C19B0B2C7DA80C00E93FD0 /* Realm in Frameworks */,
164A0A132CA3AED700504BF1 /* SDWebImageMapKit in Frameworks */,
5E2219712C6B5B5B005849FB /* Cosmos in Frameworks */,
5E22195E2C69DDB5005849FB /* SnapKit in Frameworks */,
Expand Down Expand Up @@ -475,6 +475,7 @@
16C19AD12C73AE0200E93FD0 /* UIView.swift */,
16C19ADD2C73AF6000E93FD0 /* UserDefaults.swift */,
5E42B0172C74A39300DAB751 /* MovingTextField.swift */,
1FC522262CA91ED000EC0635 /* TabBarShadow.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -865,7 +866,6 @@
5E2219702C6B5B5B005849FB /* Cosmos */,
16C19AE02C74423300E93FD0 /* SwiftyToaster */,
16C19AE52C74987600E93FD0 /* YouTubeiOSPlayerHelper */,
16C19B0A2C7DA80C00E93FD0 /* Realm */,
16C19B0C2C7DA80C00E93FD0 /* RealmSwift */,
16C19B0F2C7DB73200E93FD0 /* Then */,
164A0A102CA3AED700504BF1 /* SDWebImage */,
Expand Down Expand Up @@ -965,6 +965,7 @@
16752F9D2C5A7FB90001907D /* HexCode.swift in Sources */,
1F598F0B2C5CBD9E000CE79F /* EnterTasteTestViewController.swift in Sources */,
1F8F99FA2C6F538300EAEF6C /* WineInfoResponse.swift in Sources */,
1FC522272CA91ED000EC0635 /* TabBarShadow.swift in Sources */,
5E22196E2C6B2EA0005849FB /* RatingViewController.swift in Sources */,
1F205A432C6B66EB00E80659 /* TasteTestThirdCollectionViewCell.swift in Sources */,
1F8FECB32C74777B00704491 /* WineLikeRequest.swift in Sources */,
Expand Down Expand Up @@ -1405,11 +1406,6 @@
package = 16C19AE42C74987600E93FD0 /* XCRemoteSwiftPackageReference "youtube-ios-player-helper" */;
productName = YouTubeiOSPlayerHelper;
};
16C19B0A2C7DA80C00E93FD0 /* Realm */ = {
isa = XCSwiftPackageProductDependency;
package = 16C19B092C7DA80C00E93FD0 /* XCRemoteSwiftPackageReference "realm-swift" */;
productName = Realm;
};
16C19B0C2C7DA80C00E93FD0 /* RealmSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 16C19B092C7DA80C00E93FD0 /* XCRemoteSwiftPackageReference "realm-swift" */;
Expand Down
34 changes: 34 additions & 0 deletions Drink-EG/Drink-EG/Resources/Extensions/TabBarShadow.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// TabBarShadow.swift
// Drink-EG
//
// Created by 이현주 on 9/29/24.
//

import Foundation
import UIKit

extension CALayer {
// Sketch 스타일의 그림자를 생성하는 유틸리티 함수
func applyShadow(
color: UIColor = .black,
alpha: Float = 0.5,
x: CGFloat = 0,
y: CGFloat = 2,
blur: CGFloat = 4
) {
shadowColor = color.cgColor
shadowOpacity = alpha
shadowOffset = CGSize(width: x, height: y)
shadowRadius = blur / 2.0
}
}

extension UITabBar {
// 기본 그림자 스타일을 초기화해야 커스텀 스타일을 적용할 수 있다.
static func clearShadow() {
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
UITabBar.appearance().backgroundColor = UIColor.white
}
}
2 changes: 1 addition & 1 deletion Drink-EG/Drink-EG/Resources/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// 화면을 구성하는 UIWindow 인스턴스 생성
let window = UIWindow(windowScene: windowScene)
// 실제 첫 화면이 되는 MainViewController 인스턴스 생성
let vc = EnterLoginViewController()
let vc = MainTabBarViewController()
// NavigationController을 사용할 경우, MainViewController를 rootViewController로 갖는 NavigationController을 생성해야한다.
let navigationController = UINavigationController(rootViewController: vc)
navigationController.isNavigationBarHidden = true
Expand Down
24 changes: 12 additions & 12 deletions Drink-EG/Drink-EG/Sources/VCs/Main/MainTabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MainTabBarViewController : UITabBarController {
super.viewDidLayoutSubviews()
var tabFrame = tabBar.frame
tabFrame.size.height = 93
tabFrame.origin.y = view.frame.size.height - 93
tabFrame.origin.y = view.frame.size.height - 90
tabBar.frame = tabFrame
}

Expand All @@ -30,20 +30,20 @@ class MainTabBarViewController : UITabBarController {
let nav4 = UINavigationController(rootViewController: CommunityMainViewController())
let nav5 = UINavigationController(rootViewController: MypageViewController())

nav1.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "TabHome"), tag: 0)
nav2.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "TabClass"), tag: 1)
nav3.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "TabNote"), tag: 2)
nav4.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "TabGroup"), tag: 3)
nav5.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "TabSetting"), tag: 4)
nav1.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "TabHome"), tag: 0)
nav2.tabBarItem = UITabBarItem(title: "클래스", image: UIImage(named: "TabClass"), tag: 1)
nav3.tabBarItem = UITabBarItem(title: "테이스팅 노트", image: UIImage(named: "TabNote"), tag: 2)
nav4.tabBarItem = UITabBarItem(title: "모임", image: UIImage(named: "TabGroup"), tag: 3)
nav5.tabBarItem = UITabBarItem(title: "설정", image: UIImage(named: "TabSetting"), tag: 4)

UITabBar.clearShadow()
tabBar.layer.applyShadow(color: .gray, alpha: 0.3, x: 0, y: 0, blur: 15)

tabBar.tintColor = .label
tabBar.backgroundColor = UIColor(hue: 0, saturation: 0, brightness: 0, alpha: 0.6)
tabBar.layer.cornerRadius = 20
tabBar.layer.maskedCorners = CACornerMask(arrayLiteral: .layerMinXMinYCorner, .layerMaxXMinYCorner)
tabBar.layer.masksToBounds = true
tabBar.backgroundColor = .white

tabBar.tintColor = .white
tabBar.unselectedItemTintColor = UIColor(hue: 0, saturation: 0, brightness: 0.85, alpha: 1.0)
tabBar.tintColor = UIColor(hex: "5813B1")
tabBar.unselectedItemTintColor = UIColor(hue: 0, saturation: 0, brightness: 0, alpha: 0.5)

setViewControllers([nav1, nav2, nav3, nav4, nav5], animated: true)
}
Expand Down

0 comments on commit 22d4c43

Please sign in to comment.