SSUMC-6th / iOS_A

SSUMC 6기 iOS 스터디 A조
0 stars 0 forks source link

[Baki/week6] Layout(2) #51

Closed heemings closed 4 months ago

heemings commented 4 months ago

📍Summary

💡PR Point

HStack {
                            Image(systemName:"rectangle.split.2x2")
                                .resizable()
                                .foregroundColor(.white)
                                .frame(width: 20,height: 20)
                            Image(systemName:"bell")
                                .resizable()
                                .foregroundColor(.white)
                                .frame(width: 20, height: 20)
                            Image(systemName: "cart")
                                .resizable()
                                .foregroundColor(.white)
                                .frame(width: 20, height: 20)

                        }

이렇게 HStack, ZStack, VStack을 사용해 화면을 구현해보았습니다

let searchBar = UISearchBar()
        searchBar.placeholder = placeholder
        if let textField = searchBar.value(forKey: "searchField") as? UITextField {
            textField.backgroundColor = UIColor.white
            textField.attributedPlaceholder = NSAttributedString(string: textField.placeholder ?? "", attributes: [NSAttributedString.Key.foregroundColor : UIColor.lightGray])
            textField.textColor = UIColor.black
        }

searchBar도 구현해봤습니다

🤔 Question

스크롤 화면이 아니다 보니 화면이 center에 고정되어서 위로 고정하고 싶었는데 잘 안 됐습니다. 그래서 찾아보다 .padding(.top,getSafeArea().bottom == 0 ? 150 : -100) 다음 코드를 사용해봤는데 15버전 이상에서는 적용이 안 된다고 합니다. 이렇게 기종에 따른 레이아웃을 맞추는 정확한 방법이 궁금합니다.

🔑 Simulator

Simulator Screenshot - iPhone SE (3rd generation) - 2024-05-22 at 02 57 21 Simulator Screenshot - iPhone 14 Pro Max - 2024-05-22 at 02 58 23