iOS/Toy project

[iOS : Toy Project] Apple Framework List (2)

yevdev 2022. 5. 28. 16:32

๐Ÿ“Œ ๋‹ค์„ฏ๋ฒˆ์งธ ํ”„๋กœ์ ํŠธ (2)

Apple Framework List ์•ฑ์„ ๋” ๋งŒ์ ธ๋ณด์ž!

 

 

1๏ธโƒฃ ๊ฐ Framework Cell ๋“ค์ด ํด๋ฆญ๋˜์—ˆ์„ ๋•Œ ํšจ๊ณผ

- UICollectionViewDelegate ์˜ didSelectItemAt ๋ฉ”์†Œ๋“œ : Item์„ ์„ ํƒํ–ˆ์„ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” method

// item์ด ์„ ํƒ๋˜์—ˆ์„ ๋•Œ ํšจ๊ณผ ๋„ฃ๊ธฐ
extension FrameworkListViewController: UICollectionViewDelegate{
    
    // item์ด ์„ ํƒ๋˜์—ˆ์„ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” method
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let framework = list[indexPath.item] // ๋ช‡๋ฒˆ์งธ item์ธ์ง€?
        print(">>>> selected : \(framework.name)")
    }
}

-> console์— print๋ฌธ ์ถœ๋ ฅ!

 

 

2๏ธโƒฃ 2์—ด๋กœ ๋งŒ๋“ค๊ธฐ

let width = (collectionView.bounds.width - interItemSpacing * 1 - padding * 2) / 2

 

 

3๏ธโƒฃ 4์—ด๋กœ ๋งŒ๋“ค๊ธฐ

let width = (collectionView.bounds.width - interItemSpacing * 3 - padding * 2) / 4

โžฐ ๊ธ€์ž๋„ ์˜ˆ์˜๊ฒŒ ํ‘œ์‹œ

//  FrameworkCell.swift


import UIKit

class FrameworkCell: UICollectionViewCell {
    // ...
    override func awakeFromNib() {
        super.awakeFromNib()
        nameLabel.numberOfLines = 1
        
        // font ์‚ฌ์ด์ฆˆ๋ฅผ ์…€์— ๋”ฐ๋ผ ๋งž๊ฒŒ ์กฐ์ ˆ
        nameLabel.adjustsFontSizeToFitWidth = true
    }
    // ...
}

font size๊ฐ€ ์กฐ์ ˆ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ

 

 

3๏ธโƒฃ ๋‹ค์‹œ 3์—ด๋กœ ๋ฐ”๊พธ๊ณ  ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” ํƒ€์ดํ‹€ ๋ฐ”๊พธ๊ธฐ ( ์ฝ”๋“œ ์ƒ์—์„œ )

override func viewDidLoad() {
        super.viewDidLoad()
        collectionView.dataSource = self
        collectionView.delegate = self
        
        // ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” title ๋ฐ”๊พธ๊ธฐ
        navigationController?.navigationBar.topItem?.title = "๐ŸŽ€ Apple Frameworks"
        
        // ...
}

 

 

โžฟ ๋” ์ฐพ์•„๋ณผ๊ฒƒ

- UINavigationController

 

 


Reference

ํŒจ์ŠคํŠธ์บ ํผ์Šค ์˜จ๋ผ์ธ ๊ฐ•์˜

'iOS > Toy project' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[iOS : Toy Project] Insta Search View (2)  (0) 2022.05.29
[iOS : Toy Project] Insta Search View (1)  (0) 2022.05.29
[iOS : Toy Project] Apple Framework List (1)  (0) 2022.05.28
[iOS: Toy Project] Chat List  (0) 2022.05.23
[iOS : Toy Project] Stock Rank  (0) 2022.05.21