diff --git a/iOS_Study_B.xcodeproj/project.pbxproj b/iOS_Study_B.xcodeproj/project.pbxproj index 9763af9..89f5f0d 100644 --- a/iOS_Study_B.xcodeproj/project.pbxproj +++ b/iOS_Study_B.xcodeproj/project.pbxproj @@ -13,6 +13,12 @@ 954B6B882AC57DAA00FDCFAB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B862AC57DAA00FDCFAB /* Main.storyboard */; }; 954B6B8A2AC57DAB00FDCFAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B892AC57DAB00FDCFAB /* Assets.xcassets */; }; 954B6B8D2AC57DAB00FDCFAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B8B2AC57DAB00FDCFAB /* LaunchScreen.storyboard */; }; + CC7D89E02AE04D8D005721FE /* HomeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC7D89DE2AE04D8D005721FE /* HomeTableViewCell.swift */; }; + CC7D89E12AE04D8D005721FE /* HomeTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CC7D89DF2AE04D8D005721FE /* HomeTableViewCell.xib */; }; + CC7D89E42AE0C183005721FE /* WidthTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC7D89E22AE0C183005721FE /* WidthTableViewCell.swift */; }; + CC7D89E52AE0C183005721FE /* WidthTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CC7D89E32AE0C183005721FE /* WidthTableViewCell.xib */; }; + CC7D89E82AE0C778005721FE /* WidthCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC7D89E62AE0C778005721FE /* WidthCollectionViewCell.swift */; }; + CC7D89E92AE0C778005721FE /* WidthCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CC7D89E72AE0C778005721FE /* WidthCollectionViewCell.xib */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -24,6 +30,12 @@ 954B6B892AC57DAB00FDCFAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 954B6B8C2AC57DAB00FDCFAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 954B6B8E2AC57DAB00FDCFAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CC7D89DE2AE04D8D005721FE /* HomeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeTableViewCell.swift; sourceTree = ""; }; + CC7D89DF2AE04D8D005721FE /* HomeTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HomeTableViewCell.xib; sourceTree = ""; }; + CC7D89E22AE0C183005721FE /* WidthTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidthTableViewCell.swift; sourceTree = ""; }; + CC7D89E32AE0C183005721FE /* WidthTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WidthTableViewCell.xib; sourceTree = ""; }; + CC7D89E62AE0C778005721FE /* WidthCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidthCollectionViewCell.swift; sourceTree = ""; }; + CC7D89E72AE0C778005721FE /* WidthCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WidthCollectionViewCell.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -56,13 +68,19 @@ 954B6B7F2AC57DAA00FDCFAB /* iOS_Study_B */ = { isa = PBXGroup; children = ( + CC7D89DF2AE04D8D005721FE /* HomeTableViewCell.xib */, + CC7D89DE2AE04D8D005721FE /* HomeTableViewCell.swift */, 954B6B802AC57DAA00FDCFAB /* AppDelegate.swift */, 954B6B822AC57DAA00FDCFAB /* SceneDelegate.swift */, 954B6B842AC57DAA00FDCFAB /* ViewController.swift */, 954B6B862AC57DAA00FDCFAB /* Main.storyboard */, + CC7D89E22AE0C183005721FE /* WidthTableViewCell.swift */, + CC7D89E32AE0C183005721FE /* WidthTableViewCell.xib */, 954B6B892AC57DAB00FDCFAB /* Assets.xcassets */, 954B6B8B2AC57DAB00FDCFAB /* LaunchScreen.storyboard */, 954B6B8E2AC57DAB00FDCFAB /* Info.plist */, + CC7D89E62AE0C778005721FE /* WidthCollectionViewCell.swift */, + CC7D89E72AE0C778005721FE /* WidthCollectionViewCell.xib */, ); path = iOS_Study_B; sourceTree = ""; @@ -127,7 +145,10 @@ files = ( 954B6B8D2AC57DAB00FDCFAB /* LaunchScreen.storyboard in Resources */, 954B6B8A2AC57DAB00FDCFAB /* Assets.xcassets in Resources */, + CC7D89E52AE0C183005721FE /* WidthTableViewCell.xib in Resources */, + CC7D89E12AE04D8D005721FE /* HomeTableViewCell.xib in Resources */, 954B6B882AC57DAA00FDCFAB /* Main.storyboard in Resources */, + CC7D89E92AE0C778005721FE /* WidthCollectionViewCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -138,9 +159,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CC7D89E42AE0C183005721FE /* WidthTableViewCell.swift in Sources */, 954B6B852AC57DAA00FDCFAB /* ViewController.swift in Sources */, 954B6B812AC57DAA00FDCFAB /* AppDelegate.swift in Sources */, + CC7D89E02AE04D8D005721FE /* HomeTableViewCell.swift in Sources */, 954B6B832AC57DAA00FDCFAB /* SceneDelegate.swift in Sources */, + CC7D89E82AE0C778005721FE /* WidthCollectionViewCell.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iOS_Study_B/Assets.xcassets/1.imageset/05F907D8-8C0C-4151-967E-EB21858F071C_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/1.imageset/05F907D8-8C0C-4151-967E-EB21858F071C_4_5005_c.jpeg new file mode 100644 index 0000000..293190e Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/1.imageset/05F907D8-8C0C-4151-967E-EB21858F071C_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/1.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/1.imageset/Contents.json new file mode 100644 index 0000000..5099296 --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "05F907D8-8C0C-4151-967E-EB21858F071C_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/2.imageset/75C2B2F9-D5FC-42F2-A30F-5754722D7A14_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/2.imageset/75C2B2F9-D5FC-42F2-A30F-5754722D7A14_4_5005_c.jpeg new file mode 100644 index 0000000..fef7cbb Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/2.imageset/75C2B2F9-D5FC-42F2-A30F-5754722D7A14_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/2.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/2.imageset/Contents.json new file mode 100644 index 0000000..1b81fb8 --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "75C2B2F9-D5FC-42F2-A30F-5754722D7A14_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/3.imageset/79D54278-037C-4C2F-ABA6-645DDF034B9E_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/3.imageset/79D54278-037C-4C2F-ABA6-645DDF034B9E_4_5005_c.jpeg new file mode 100644 index 0000000..1d63abe Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/3.imageset/79D54278-037C-4C2F-ABA6-645DDF034B9E_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/3.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/3.imageset/Contents.json new file mode 100644 index 0000000..e36cc64 --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "79D54278-037C-4C2F-ABA6-645DDF034B9E_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/4.imageset/958975E1-F63C-4AE3-8A63-A697920C674B_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/4.imageset/958975E1-F63C-4AE3-8A63-A697920C674B_4_5005_c.jpeg new file mode 100644 index 0000000..f2a5a64 Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/4.imageset/958975E1-F63C-4AE3-8A63-A697920C674B_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/4.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/4.imageset/Contents.json new file mode 100644 index 0000000..8ea002a --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/4.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "958975E1-F63C-4AE3-8A63-A697920C674B_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/5.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/5.imageset/Contents.json new file mode 100644 index 0000000..83927fd --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/5.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "D3046DAA-BB6E-40DE-98F3-E3ABA1E3D233_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/5.imageset/D3046DAA-BB6E-40DE-98F3-E3ABA1E3D233_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/5.imageset/D3046DAA-BB6E-40DE-98F3-E3ABA1E3D233_4_5005_c.jpeg new file mode 100644 index 0000000..4cad3f1 Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/5.imageset/D3046DAA-BB6E-40DE-98F3-E3ABA1E3D233_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/6.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/6.imageset/Contents.json new file mode 100644 index 0000000..03fece1 --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/6.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "DBE259E1-4611-4E85-B031-9C35A68565D2_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/6.imageset/DBE259E1-4611-4E85-B031-9C35A68565D2_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/6.imageset/DBE259E1-4611-4E85-B031-9C35A68565D2_4_5005_c.jpeg new file mode 100644 index 0000000..1ed45d1 Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/6.imageset/DBE259E1-4611-4E85-B031-9C35A68565D2_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/7.imageset/57B6379E-283A-4023-BBC1-4BADD6D89301_4_5005_c.jpeg b/iOS_Study_B/Assets.xcassets/7.imageset/57B6379E-283A-4023-BBC1-4BADD6D89301_4_5005_c.jpeg new file mode 100644 index 0000000..e17a258 Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/7.imageset/57B6379E-283A-4023-BBC1-4BADD6D89301_4_5005_c.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/7.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/7.imageset/Contents.json new file mode 100644 index 0000000..e7f30a0 --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/7.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "57B6379E-283A-4023-BBC1-4BADD6D89301_4_5005_c.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/8.imageset/8.jpeg b/iOS_Study_B/Assets.xcassets/8.imageset/8.jpeg new file mode 100644 index 0000000..d533a13 Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/8.imageset/8.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/8.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/8.imageset/Contents.json new file mode 100644 index 0000000..b2fa26b --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/8.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "8.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Assets.xcassets/9.imageset/9.jpeg b/iOS_Study_B/Assets.xcassets/9.imageset/9.jpeg new file mode 100644 index 0000000..c7a2a5c Binary files /dev/null and b/iOS_Study_B/Assets.xcassets/9.imageset/9.jpeg differ diff --git a/iOS_Study_B/Assets.xcassets/9.imageset/Contents.json b/iOS_Study_B/Assets.xcassets/9.imageset/Contents.json new file mode 100644 index 0000000..86bbbf6 --- /dev/null +++ b/iOS_Study_B/Assets.xcassets/9.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "9.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_B/Base.lproj/Main.storyboard b/iOS_Study_B/Base.lproj/Main.storyboard index 25a7638..434c987 100644 --- a/iOS_Study_B/Base.lproj/Main.storyboard +++ b/iOS_Study_B/Base.lproj/Main.storyboard @@ -1,24 +1,210 @@ - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS_Study_B/HomeTableViewCell.swift b/iOS_Study_B/HomeTableViewCell.swift new file mode 100644 index 0000000..7ad2dcf --- /dev/null +++ b/iOS_Study_B/HomeTableViewCell.swift @@ -0,0 +1,28 @@ +// +// HomeTableViewCell.swift +// iOS_Study_B +// +// Created by 임아영 on 2023/10/19. +// + +import UIKit + +class HomeTableViewCell: UITableViewCell { + @IBOutlet weak var price: UILabel! + @IBOutlet weak var subimage: UIImageView! + @IBOutlet weak var imageview: UIImageView! + @IBOutlet weak var sub: UILabel! + @IBOutlet weak var title: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/iOS_Study_B/HomeTableViewCell.xib b/iOS_Study_B/HomeTableViewCell.xib new file mode 100644 index 0000000..1e44220 --- /dev/null +++ b/iOS_Study_B/HomeTableViewCell.xib @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS_Study_B/ViewController.swift b/iOS_Study_B/ViewController.swift index f3577b5..08b7ddc 100644 --- a/iOS_Study_B/ViewController.swift +++ b/iOS_Study_B/ViewController.swift @@ -8,12 +8,116 @@ import UIKit class ViewController: UIViewController { - + + @IBOutlet weak var tableView: UITableView! + override func viewDidLoad() { super.viewDidLoad() + + tableView.delegate = self + tableView.dataSource = self + let HomeNib = UINib(nibName: "HomeTableViewCell", bundle: nil) + tableView.register(HomeNib, forCellReuseIdentifier: "HomeTableViewCell") + let WidthNib = UINib(nibName: "WidthTableViewCell", bundle: nil) + tableView.register(WidthNib, forCellReuseIdentifier: "WidthTableViewCell") // Do any additional setup after loading the view. } +} + +extension ViewController: UITableViewDelegate, UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 4 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.row == 0 { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTableViewCell", for: indexPath) as? HomeTableViewCell else { + return UITableViewCell() + } + //1.사진 교체 + cell.imageview.image = UIImage(named: "1") + //2.상품이름 교체 + cell.title.text = "에어팟맥스 [S급] 스페이스 그래이 최상\n급상태 팝니다~!!" + //3.상품판매 위치 교체 + cell.sub.text = "당근알바﹒이벤트" + cell.subimage.isHidden = true + cell.price.isHidden = true + + return cell + } + else if indexPath.row == 1{ + guard let cell = tableView.dequeueReusableCell(withIdentifier: "WidthTableViewCell", for: indexPath) as? WidthTableViewCell else { + return UITableViewCell() + } + return cell + } + else if indexPath.row == 2 { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTableViewCell", for: indexPath) as? HomeTableViewCell else { + return UITableViewCell() + } + //1.사진 교체 + cell.imageview.image = UIImage(named: "4") + //2.상품이름 교체 + cell.title.text = "에어팟맥스 실버(미개봉)" + //3.상품판매 위치 교체 + cell.sub.text = "서울특별시 구로구﹒5시간 전" + cell.subimage.image = UIImage(named: "7") + cell.price.text = "600,000원" + return cell + } + if indexPath.row == 3 { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTableViewCell", for: indexPath) as? HomeTableViewCell else { + return UITableViewCell() + } + //1.사진 교체 + cell.imageview.image = UIImage(named: "6") + //2.상품이름 교체 + cell.title.text = "메가하이볼!!" + //3.상품판매 위치 교체 + cell.sub.text = "광명동﹒추천소식" + cell.subimage.isHidden = true + cell.price.isHidden = true + return cell + } + else { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTableViewCell", for: indexPath) as? HomeTableViewCell else { + return UITableViewCell() + } + return cell + } + + + } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + + if indexPath.row == 1 { + return 200 + } else { + return 170 } + } + func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + guard let tableViewCell = cell as? WidthTableViewCell else { + return + } + } } + +extension ViewController : UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 4 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "WidthCollectionViewCell", for: indexPath) as? WidthCollectionViewCell else { + return UICollectionViewCell() + } + return cell + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: 100, height: 200) + } +} diff --git a/iOS_Study_B/WidthCollectionViewCell.swift b/iOS_Study_B/WidthCollectionViewCell.swift new file mode 100644 index 0000000..105a08f --- /dev/null +++ b/iOS_Study_B/WidthCollectionViewCell.swift @@ -0,0 +1,22 @@ +// +// WidthCollectionViewCell.swift +// iOS_Study_B +// +// Created by 임아영 on 2023/10/19. +// + +import UIKit + +class WidthCollectionViewCell: UICollectionViewCell { + @IBOutlet weak var widthsub: UILabel! + @IBOutlet weak var widthtitle: UILabel! + @IBOutlet weak var widthimageview: UIImageView! + + override func awakeFromNib() { + super.awakeFromNib() + + widthimageview.layer.cornerRadius = 10 + // Initialization code + } + +} diff --git a/iOS_Study_B/WidthCollectionViewCell.xib b/iOS_Study_B/WidthCollectionViewCell.xib new file mode 100644 index 0000000..a76ff85 --- /dev/null +++ b/iOS_Study_B/WidthCollectionViewCell.xib @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS_Study_B/WidthTableViewCell.swift b/iOS_Study_B/WidthTableViewCell.swift new file mode 100644 index 0000000..ffbbf81 --- /dev/null +++ b/iOS_Study_B/WidthTableViewCell.swift @@ -0,0 +1,91 @@ +// +// WidthTableViewCell.swift +// iOS_Study_B +// +// Created by 임아영 on 2023/10/19. +// + +import UIKit + +class WidthTableViewCell: UITableViewCell { + @IBOutlet weak var collectionView: UICollectionView! + + var model = [String]() + + override func awakeFromNib() { + super.awakeFromNib() + + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .horizontal + collectionView.collectionViewLayout = layout + + collectionView.delegate = self + collectionView.dataSource = self + + collectionView.register(UINib(nibName: "WidthCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "WidthCollectionViewCell") + // Initialization code + } + + + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + + } + +extension WidthTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout{ + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {return 4} + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "WidthCollectionViewCell", for: indexPath) as? WidthCollectionViewCell else { + return UICollectionViewCell() + } + + if indexPath.row == 0 { + //1. 사진 교체 + cell.widthimageview.image = UIImage(named:"8") + //2. 상품명 교체 + cell.widthtitle.text = "곰돌이 모양 틀 얼음 판매, 새 것" + //3. 상품 가격 교체 + cell.widthsub.text = "3,000원" + } + if indexPath.row == 1 { + //1. 사진 교체 + cell.widthimageview.image = UIImage(named:"3") + //2. 상품명 교체 + cell.widthtitle.text = "키친플라워 DW1201CP 얼음 제빙기" + //3. 상품 가격 교체 + cell.widthsub.text = "62,000원" + } + if indexPath.row == 2 { + //1. 사진 교체 + cell.widthimageview.image = UIImage(named:"5") + //2. 상품명 교체 + cell.widthtitle.text = "얼음트레이 소(얼음판)/개당 판매 가능합니다!" + //3. 상품 가격 교체 + cell.widthsub.text = "1,000원" + } + if indexPath.row == 3 { + //1. 사진 교체 + cell.widthimageview.image = UIImage(named:"9") + //2. 상품명 교체 + cell.widthtitle.text = "실리콘얼음틀" + //3. 상품 가격 교체 + cell.widthsub.text = "2,000원" + } + return cell + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + return CGSize(width: 138, height: 230) + } + + func collectionView(_ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 13 + } +} diff --git a/iOS_Study_B/WidthTableViewCell.xib b/iOS_Study_B/WidthTableViewCell.xib new file mode 100644 index 0000000..8cc3a59 --- /dev/null +++ b/iOS_Study_B/WidthTableViewCell.xib @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +