24.06.26 Today I Learned

2024. 6. 26. 20:52·Today I Learned/2024

 

 

 구현할 때 버튼이 사각형으로 되있길래 동그랗게 만드는거로 마무리 지었다

.layerconerRadius로 하는거로 코드를 입력해봤는데 적용이 잘 안되는거 같아서 아래의 방법으로 구현했다.

 

이젠 코드베이스로 구현해보는걸 해야겠다.


 

일단은 버튼을 화면에 구현하고 컬러를 Asset에 추가해서 이전에 쓰던 컬러와 최대한 비슷한 색을 찾아서 만들고 그 컬러를 custom으로 불러오는 걸 해봤다.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            HStack {
                Text("7")
                    .frame(width:80, height:80) // 백그라운드 프레임
                    .background(.number) // 백그라운드 컬러
                    .cornerRadius(40) // 원형으로 깎는 것
                    .foregroundColor(.white) // 텍스트 컬러
                    .font(.system(size:30)) // 텍스트 스타일 및 사이즈
                    .bold() // 텍스트 볼드체
                Text("8")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("9")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("×")
                    .frame(width:80, height:80)
                    .background(.orange)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
            }
            HStack {
                Text("4")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("5")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("6")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("-")
                    .frame(width:80, height:80)
                    .background(.orange)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
            }
            HStack {
                Text("1")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("2")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("3")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("+")
                    .frame(width:80, height:80)
                    .background(.orange)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
            }
            HStack {
                Text("AC")
                    .frame(width:80, height:80)
                    .background(.orange)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("0")
                    .frame(width:80, height:80)
                    .background(.number)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("=")
                    .frame(width:80, height:80)
                    .background(.orange)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
                Text("÷")
                    .frame(width:80, height:80)
                    .background(.orange)
                    .cornerRadius(40)
                    .foregroundColor(.white)
                    .font(.system(size:30))
                    .bold()
            }
        }
    }
}
    #Preview {
        ContentView()
    }

'Today I Learned > 2024' 카테고리의 다른 글

24.06.28 Today I Learned  (0) 2024.06.28
24.06.27 Today I Learned  (0) 2024.06.27
24.06.25 Today I Learned  (0) 2024.06.25
24.06.24 Today I Learned  (0) 2024.06.24
24.06.21 Today I Learned  (0) 2024.06.21
'Today I Learned/2024' 카테고리의 다른 글
  • 24.06.28 Today I Learned
  • 24.06.27 Today I Learned
  • 24.06.25 Today I Learned
  • 24.06.24 Today I Learned
이도서
이도서
  • 이도서
    도서의 코딩노트
    이도서
  • 전체
    오늘
    어제
    • 분류 전체보기 (209)
      • Today I Learned (79)
        • 2024 (78)
      • Swift (25)
        • Swift 문법 정리 (19)
        • RxSwift (5)
      • Swift Study (12)
        • Playground (2)
        • Storyboard (9)
        • UIKit (1)
      • Git (3)
      • 코딩테스트 (60)
      • Dart 언어 (16)
      • Flutter (11)
        • Flutter Study (11)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

    • 개발 공부 공유 링크
  • 인기 글

  • 태그

    코딩 테스트
    객체지향
    Flutter
    DART
    코딩테스트
    Xcode
    ios앱개발자
    코딩테스트 level.1
    storyboard
    내일배움캠프
    iOS앱개발
    코딩테스트Level.1
    구조체
    Playground
    계산기만들기
    ios
    widget
    Til
    함수
    Swift
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
이도서
24.06.26 Today I Learned
상단으로

티스토리툴바