Skip to content

Commit

Permalink
[#12] 셀 아래쪽에 실선(border) 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
chongin12 committed Jan 2, 2025
1 parent 1f49d00 commit 0dbd869
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Handy/Handy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
02ED764C2C57BD09001569F1 /* HandyBoxButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02ED764B2C57BD09001569F1 /* HandyBoxButtonViewController.swift */; };
2D41E8142C5A21930043161D /* FabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D41E8132C5A21930043161D /* FabViewController.swift */; };
2D41E8162C5A21B50043161D /* HandyFab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D41E8152C5A21B50043161D /* HandyFab.swift */; };
6F1A18D02D26606D004C6083 /* CALayer+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F1A18CF2D26606A004C6083 /* CALayer+.swift */; };
6FD1A1802D213129001E6F2E /* TabsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FD1A17F2D21311C001E6F2E /* TabsViewController.swift */; };
6FE73E942D23C52F00E06422 /* HandyTabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FE73E932D23C52C00E06422 /* HandyTabs.swift */; };
6FE73E962D23C55900E06422 /* HandyTabCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FE73E952D23C55900E06422 /* HandyTabCell.swift */; };
Expand Down Expand Up @@ -119,6 +120,7 @@
02ED764B2C57BD09001569F1 /* HandyBoxButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyBoxButtonViewController.swift; sourceTree = "<group>"; };
2D41E8132C5A21930043161D /* FabViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FabViewController.swift; sourceTree = "<group>"; };
2D41E8152C5A21B50043161D /* HandyFab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyFab.swift; sourceTree = "<group>"; };
6F1A18CF2D26606A004C6083 /* CALayer+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CALayer+.swift"; sourceTree = "<group>"; };
6FD1A17F2D21311C001E6F2E /* TabsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsViewController.swift; sourceTree = "<group>"; };
6FE73E932D23C52C00E06422 /* HandyTabs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyTabs.swift; sourceTree = "<group>"; };
6FE73E952D23C55900E06422 /* HandyTabCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandyTabCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -319,6 +321,7 @@
02ED76482C577998001569F1 /* Extension */ = {
isa = PBXGroup;
children = (
6F1A18CF2D26606A004C6083 /* CALayer+.swift */,
02ED76492C5779C3001569F1 /* UIImage+.swift */,
);
path = Extension;
Expand Down Expand Up @@ -512,6 +515,7 @@
E5669A3F2C443E7300DABC21 /* HandyBasicColor.swift in Sources */,
02ED76312C5284BB001569F1 /* HandyButtonProtocol.swift in Sources */,
02ED76352C5284F3001569F1 /* HandyTextButton.swift in Sources */,
6F1A18D02D26606D004C6083 /* CALayer+.swift in Sources */,
A5F6D36B2C96F32D00FB961F /* HandyDivider.swift in Sources */,
02BDB7FC2C3E99920050FB67 /* HandyFont.swift in Sources */,
6FE73E962D23C55900E06422 /* HandyTabCell.swift in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions Handy/Handy/Source/Atom/HandyTabs/HandyTabCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ open class HandyTabCell: UICollectionViewCell {
fatalError("init(coder:) has not been implemented")
}

// MARK: - layoutSubviews
open override func layoutSubviews() {
super.layoutSubviews()
layer.addBorder([.bottom], color: HandySemantic.lineBasicLight, width: 1)
}

// MARK: - private methods

private func initializeViewHierarchy() {
Expand Down
8 changes: 6 additions & 2 deletions Handy/Handy/Source/Atom/HandyTabs/HandyTabs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ open class HandyTabs: UIViewController {
public init(sizeType: HandyTabCell.SizeType) {
self.sizeType = sizeType
super.init(nibName: nil, bundle: nil)
setTabsHeader()
setTabsContent()
}

required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

open override func viewDidLoad() {
super.viewDidLoad()
setTabsHeader()
setTabsContent()
}

// MARK: - private methods

/// Tabs Header 부분을 만드는 메소드입니다.
Expand Down
36 changes: 36 additions & 0 deletions Handy/Handy/Source/Extension/CALayer+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CALayer+.swift
// Handy
//
// Created by chongin on 1/2/25.
//

import UIKit

extension CALayer {

/// view의 layer에서 특정 모서리에만 border를 적용시킵니다.
/// - Parameters:
/// - edges: 적용하고 싶은 모서리의 방향입니다. `.top`, `.bottom,` `.left`, `.right`를 사용할 수 있습니다. `.all`은 사용할 수 없습니다.
/// - color: border의 색상입니다.
/// - width: border의 두께입니다.
func addBorder(_ edges: [UIRectEdge], color: UIColor, width: CGFloat) {
edges.forEach { edge in
let border = CALayer()
switch edge {
case .top:
border.frame = CGRect(x: 0, y: 0, width: frame.width, height: width)
case .bottom:
border.frame = CGRect(x: 0, y: frame.height - width, width: frame.width, height: width)
case .left:
border.frame = CGRect(x: 0, y: 0, width: width, height: frame.height)
case .right:
border.frame = CGRect(x: frame.width - width, y: 0, width: width, height: frame.height)
default:
break
}
border.backgroundColor = color.cgColor
addSublayer(border)
}
}
}

0 comments on commit 0dbd869

Please sign in to comment.