Skip to content

Latest commit

ย 

History

History
219 lines (122 loc) ยท 8.79 KB

third_Assignment_Readme.md

File metadata and controls

219 lines (122 loc) ยท 8.79 KB

3์ฃผ์ฐจ ๊ณผ์ œ

3แ„Œแ…ฎแ„Žแ…ก แ„€แ…ชแ„Œแ…ฆ แ„ƒแ…ขแ„†แ…ฎแ†ซ

ํŒŒ์ผ๋กœ ์ด๋™ํ•˜๊ธฐ

๋ชฉํ‘œ : CollectionView๋ฅผ ํ™œ์šฉํ•ด ๋ ˆ์ด์•„์›ƒ ๊ตฌ์„ฑํ•ด์„œ ์Šคํฌ๋กค ํ•˜๊ธฐ

๊ตฌํ˜„ ๊ฒฐ๊ณผ๋ฌผ
collectionView


2์ฃผ์ฐจ์™€ ๋น„์Šทํ•œ ๊ณผ์ œ์ง€๋งŒ, 2์ฃผ์ฐจ์—์„œ๋Š” Stack์„ ์ด์šฉํ•ด ๋ทฐ๋ฅผ ์ž‘์„ฑํ–ˆ๋‹ค๋ฉด์€ ์ด๋ฒˆ์—๋Š” CollectionView๋ฅผ ํ™œ์šฉํ•ด ๋ทฐ๋ฅผ ์ž‘์„ฑํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค!

๋ทฐ ๊ตฌ์กฐ ์žก๊ธฐ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 1 31 38

์ด์ „ 2์ฃผ์ฐจ์™€ ๋™์ผํ•˜๊ฒŒ, ์œ„์— ํ”„๋กœํ•„ ์ž‘์„ฑํ•˜๊ธฐ ๋ฒ„ํŠผ๊ณผ ๋กœ๊ณ ์ชฝ์„ ๋„ฃ๊ธฐ ์œ„ํ•ด headerView๋ฅผ ์‚ฌ์šฉํ–ˆ๊ณ ,

๋ฐ‘์—๋Š” scrollView์•ˆ์— mainContainerView๋ฅผ ์ฑ„์šด ๋’ค์—

๋„ฃ๊ณ ์‹ถ์€ ๋ฐฐ๋„ˆ ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ์–ด์ฃผ๊ณ 

2์ฃผ์ฐจ์™€ ๋‹ฌ๋ผ์ง„ ์ ์€ "CollectionView"๋ฅผ ๋„ฃ์–ด์ฃผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค!!

ํ˜„์žฌ ๋ชจ๋“  ์ปฌ๋ ‰์…˜ ์…€์ด ๋™์ผํ•œ ๊ตฌ์„ฑ์œผ๋กœ ๋˜์–ด ์žˆ๊ธฐ์— CollectionView์— ํ•˜๋‚˜์˜ ์…€๋งŒ ์˜ฌ๋ ค์„œ ์ž‘์„ฑ์„ ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!!

CollectionView ์„ค์ •

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 1 35 17

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ปฌ๋ ‰์…˜ ๋ทฐ์— ๋Œ€ํ•ด delegate์™€ dataSource์— ๋Œ€ํ•ด ์„ค์ •์„ ํ•ด์ค๋‹ˆ๋‹ค!

3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜์—์„œ ๋ฐฐ์šด๋Œ€๋กœ ์ฐจ๊ทผ์ฐจ๊ทผ ๋”ฐ๋ผํ•˜๋ฉด ๋ทฐ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š”๋ฐ๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์ง€๋งŒ!

UICollectionViewDelegateFlowLayout ๋ฅผ ํ™œ์šฉํ•ด ์…€๋“ค์˜ ํฌ๊ธฐ ๋ฐ ๋งˆ์ง„์„ ์žก์•„๋ณด๋„๋ก ํ•ฉ๋‹ˆ๋‹ค!!

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 1 38 15

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 1 39 20

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 1 38 03

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 10 22 34

๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฉ”์†Œ๋“œ๋ฅผ ํ™œ์šฉํ•ด Cell ์˜ ํฌ๊ธฐ ๋ฐ ์œ„์น˜ / ๋งˆ์ง„์„ ์žก์•„๋‘๋ฉด ๋ฉ๋‹ˆ๋‹ค!!

๋‹ค ๋งž๊ฒŒ ์„ธํŒ…ํ›„, ์‹คํ–‰ํ–ˆ์„ ๋•Œ, ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ถœ๋ ฅ ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด

์Šคํ† ๋ฆฌ๋ณด๋“œ UICollectionView ์ธ์ŠคํŽ™ํ„ฐ์—์„œ
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 1 40 54
"estimate Size"์— ๋Œ€ํ•ด์„œ none์„ ์ฒ˜๋ฆฌํ•ด์ฃผ๋ฉด ์‰ฝ๊ฒŒ ๋ ˆ์ด์•„์›ƒ์ด ์›ํ•˜๋Š”๋Œ€๋กœ ๊ตฌ์„ฑ๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!



์Šคํฌ๋กค ์„ค์ •

ScrollVIew ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ๋‚ด๋ถ€ container ๋ทฐ์— ์žˆ๋Š” ์š”์†Œ๋“ค์˜ ๋†’์ด๊ฐ€ ์ •ํ™•ํžˆ ๊ฒฐ์ • ๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์Šคํฌ๋กค ๋ทฐ ์•ˆ์— ๋ฐฐ๋„ˆ ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ๊ณ , ์ปฌ๋ ‰์…˜ ๋ทฐ๋ฅผ ๋„ฃ๊ณ  ์งค ๋•Œ, ๋†’์ด๋ฅผ ๊ฒฐ์ •ํ•ด์•ผ ์ „์ฒด๊ฐ€ ์Šคํฌ๋กค์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค!!

์ปฌ๋ ‰์…˜๋ทฐ์˜ ๋†’์ด๋ฅผ ๊ฒฐ์ •ํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด?

์ปฌ๋ ‰์…˜๋ทฐ์˜ ๋†’์ด๊ฐ€ ๊ฒฐ์ •๋˜์ง€ ์•Š์•„ ์ƒ์œ„์— ์žˆ๋Š” ์Šคํฌ๋กค๋ทฐ๋Š” ์ปฌ๋ ‰์…˜๋ทฐ์˜ ๋†’์ด๋ฅผ ๋ชจ๋ฅด๊ธฐ๋•Œ๋ฌธ์— ์ „์ฒด ์Šคํฌ๋กค์ด ๋˜์ง€ ์•Š๊ณ  ๋‚ด๋ถ€์— ์žˆ๋Š” ์ปฌ๋ ‰์…˜๋ทฐ์—์„œ๋งŒ ์Šคํฌ๋กค์ด ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค,,

์ปฌ๋ ‰์…˜๋ทฐํ•˜๊ณ  ์Šคํฌ๋กค๋ทฐ์˜ ์Šคํฌ๋กค์ด ๋”ฐ๋กœ ๋†€๊ณ  ์žˆ๋‹ค๋ฉด??

์ปฌ๋ ‰์…˜๋ทฐ์—๋„ ์Šคํฌ๋กค์ด ๋จน๊ณ , ์ƒ์œ„ ์Šคํฌ๋กค๋ทฐ์—๋„ ์Šคํฌ๋กค์ด ๋จน๋Š”๋‹ค๋ฉด ๋ฏธ๋ฌ˜ํ•˜๊ฒŒ ์Šคํฌ๋กค ์•ก์…˜์ด ์ด์ƒํ•œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

์ด๋ ‡๊ฒŒ ๋˜์—ˆ์„ ๊ฒฝ์šฐ์—๋Š”, ๋‚ด๋ถ€ ์ปฌ๋ ‰์…˜ ๋ทฐ์— ๋Œ€ํ•ด height ๋ฅผ ๊ฑธ๊ณ , User Interaction, ์ฆ‰ ์ปฌ๋ ‰์…˜ ๋ทฐ์— ๋Œ€ํ•ด ์Šคํฌ๋กค์„ ์•ˆ๋จน๊ฒŒ ํ•œ ๋’ค์—

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2020-11-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 10 27 20

์ปฌ๋ ‰์…˜ ๋ทฐ์— ๋Œ€ํ•ด ๋†’์ด๋ฅผ ๋‚ญ๋‚ญํ•˜๊ฒŒ... ์ ๋‹นํ•˜๊ฒŒ.. ๋†’๊ฒŒ ์„ค์ •ํ•ด์ฃผ๋ฉด ์Šคํฌ๋กค์ด ๊น”๋”ํ•˜๊ฒŒ ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!!

(์ „์ฒด ์ฝ”๋“œ)

//
//  ViewController.swift
//  thirdWeek_Assignment
//
//  Created by ์†ก์ง€ํ›ˆ on 2020/11/01.
//

import UIKit

class ViewController: UIViewController {

    
    var userDataList : [userData] = []
    @IBOutlet weak var userCollectionView: UICollectionView!
    override func viewDidLoad() {
        super.viewDidLoad()
        settingCollectionView()
        settingData()
        
    }
    
    func settingCollectionView()
    {
        self.userCollectionView.delegate = self
        self.userCollectionView.dataSource = self
    }
    
    func settingData()
    {
        self.userDataList.append(contentsOf: [
        
            userData(name: "์ด์ฃผํ˜", imageName: "juhyeok", description: "#hereis#์•„์š”#๋‚ด๊ฟˆ์€#์‚ฌ๊ณผ๋†์žฅ#ENFP"),
            userData(name: "๊น€๋‚˜์—ฐ", imageName: "nayeon", description: "#์ด์ œ๋ง‰ํ•™๊ธฐ #์—ฌ๋Ÿฌ๋ถ„๋“ค์ด๋ž‘_์นœํ•ด์ง€๊ณ _์‹ถ์–ด์š”#๋ฒˆ๊ฐœ์Šคํ„ฐ๋””ํ™˜์˜"),
            userData(name: "์†ํ‰ํ™”", imageName: "peace", description: "#ํ•ธ๋“œํ”ผ์“ฐ #์ด๋„ˆํ”ผ์“ฐ #๋ฐฐ๊ผฝ๋„๋‘‘#ํ—ฌ๋ฆฐ์ด #sson_peace7"),
            userData(name: "์œ ํฌ์ˆ˜", imageName: "heesoo", description: "#์ด๋ฌด๊ฟˆ๋‚˜๋ฌด #์œ ์ด๋ฌด #ํ˜„์žฌ_์†Œ์‹์ค‘ #ํ’‰"),
            userData(name: "๋ฐ•์„ธ์€", imageName: "saeeun", description: "#๋งˆ #์•„์š”๋Š” #์ฒ˜์Œ์ž…๋‹ˆ๋‹ค"),
            userData(name: "ํ•œ์šธ", imageName: "wool", description: "#ENFP #STORM #์šธํฌ๋ฐ•์Šค #@hwooolll #ํ•˜๋Š˜์ฝœ๋ ‰ํ„ฐ"),
            userData(name: "๊น€ํ•œ์†”", imageName: "hansol", description: "#๊ณ ๊ฐ์ค‘์‹ฌ#๊ณ ๊ฐํ–‰๋™๋ฐ์ดํ„ฐ๊ธฐ๋ฐ˜ํ•œ#UX๋””์ž์ด๋„ˆ#์›Œ๋„ˆ๋น„,,"),
            userData(name: "๋ฐฐ๋ฏผ์ฃผ", imageName: "minju", description: "#๋””ํŒŸ์žฅ #๊ฐœ์ž์ด๋„ˆ #์ตœ์ข…๋ชฉํ‘œ๋Š”ํ–‰๋ณต"),
            userData(name: "์ตœ์˜ํ›ˆ", imageName: "younghun", description: "#์„œํŒŸ์งฑ #์†ํŠธ3ํšŒ์ฐจ #์•ฑ์žผ_์š”๋ฆฌ_๊ฐœ๋ฐœ์ž #UX/UI"),
            userData(name: "๊ฐ•๋ฏผ๊ตฌ", imageName: "minguru", description: "#๋ฐ๋งน #์•ˆํŒŸ์žฅ #์ด๋ž˜๋ตˆ๋„_๊ท€์—ฌ์šด๊ฑฐ์ข‹์•„ํ•จ #์ง€๋ฐ•๋ น #ํ—ˆ๋‹น"),
            userData(name: "์ด์ •์—ฐ", imageName: "yeonjeong", description: "#ํ”Œ๋ ˆ์ด์Šคํ”ฝ #ENFJ #๊ธฐํš_๋””์ž์ธ_๊ฐœ๋ฐœ_๋‹ค"),
            userData(name: "ํ™์ค€์—ฝ", imageName: "junyeop", description: "#26๊ธฐ์„œ๋ฒ„ #27๊ธฐ์›น #์ƒต์ด_๋‘๊ฐœ๋ฉด_์–ด๋–ป๊ฒŒ๋ ๊นŒ? ##")
        
        ])
        
        
    }


}

extension ViewController : UICollectionViewDelegate
{
}

extension ViewController : UICollectionViewDataSource
{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return userDataList.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        
        guard let userCell = collectionView.dequeueReusableCell(withReuseIdentifier: "userCell", for: indexPath) as? userCollectionCell else {return UICollectionViewCell() }
        
        
        userCell.settingData(name: userDataList[indexPath.row].name, imageName: userDataList[indexPath.row].imageName, description:userDataList[indexPath.row].description )
        
        return userCell
    }
    
}

extension ViewController : UICollectionViewDelegateFlowLayout
{
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        
        let width = (self.userCollectionView.frame.width - 27) / 2
        let height =  width * 1.5
        
        return CGSize(width: width, height: height)
        
        
        
    }
    

    
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout:
    UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 0
        
    }
    
    



    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout:
    UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
    return 0
    }
    
    
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout:
    UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
    return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    }
    
    
}