์ตœ์Šน๊ธฐ

@cellpig

45 Points

0 Followers

21 Posts

Joined April 27th, 2021

User has not added any information in their about section.

View Post

[SwiftUI] Extract Functions & Views

Extract Functions & View function์„ ๋งŒ๋“ค๊ณ  ์ ์šฉํ•œ๋‹ค. buttonPress() ์šฐํด๋ฆญํ›„ jump to definition์œผ๋กœ ์ฐพ์•„ ๊ฐˆ ์ˆ˜ ์žˆ๋‹ค. ๋ทฐ๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ์ƒˆ๋กœ์šด ๋ทฐ๋ฅผ ๋งŒ๋“ค์ˆ˜ ์žˆ๋‹ค. ์›ํ•˜๋Š” ๋ทฐ๋ฅผ ์„ ํƒํ•œ ํ›„ var body: .. ๋กœ ๋ถ„๋ฆฌํ•œ๋‹ค. ์ด๊ฒƒ์€ ํ•œ ๊ตฌ์กฐ์ฒด ์•ˆ์—์„œ ์ด๋ฃจ์–ด ์ง„๋‹ค. ๊ตฌ์กฐ์ฒด ๋ฐ”๊นฅ์œผ๋กœ ๋นผ๊ณ  ์ƒˆ๋กœ์šด ๊ตฌ์กฐ์ฒด๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒฝ์šฐ๋Š” ๊ตฌ์กฐ์ฒด() ์˜ ํ˜•ํƒœ๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ  ๊ตฌ์กฐ์ฒด...
Select One:
View Post

[SwiftUI] @State

@State property wrapper code struct StateBootcamp: View { // ๋‹ค์Œ์˜ ๋ณ€์ˆ˜๋ฅผ ๋ทฐ ๊ฐ€ ์•Œ์•„์•ผ ํ•œ๋‹ค. ๊ทธ๋ž˜์„œ property wrapper๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. // @State๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ทฐ๊ฐ€ ํ•ญ์ƒ ๊ฐ์‹œํ•˜๊ณ  ์žˆ๋‹ค๊ฐ€ ๋ณ€ํ™”๊ฐ€ ์žˆ์œผ๋ฉด ์ ์šฉํ•œ๋‹ค. @State var backgroundColor: Color = Color.green @State var myTitle: String = "My Title" @State...
Select One:
View Post

[SwiftUI] Button()

Button() struct ButtonsBootcamp: View { // ์•„๋ž˜๋Š” ๋ณ€์ˆ˜๋Š” @State๋ฅผ ๋ถ™์ด์ง€ ์•Š์œผ๋ฉด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. @State var title: String = "This is my title" var body: some View { VStack(spacing:20){ Text(title) // ํ…์ŠคํŠธ์™€ ์•ก์…˜๋งŒ ๊ฐ–๊ณ  ์žˆ๋Š” ๋ฒ„ํŠผ์˜ ์˜ˆ Button("Press...
Select One:
View Post

[SwiftUI] SafeArea

.ignoresSafeArea() .edgesIgnoringSafeArea() ์• ํ”Œ ๋””๋ฒจ๋กญํผ ์‚ฌ์ดํŠธ์—์„œ Human Interface Guidelines๋ฅผ ์ฐธ๊ณ ํ•œ๋‹ค. Visual Design ํ•ญ๋ชฉ์„ ์ฐธ๊ณ ํ•จ ์• ํ”Œ์—์„œ๋Š” .edgesIgnoringSafeArea() ๋Œ€์‹  .ignoresSafeArea()๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.(ios 14 ์ด์ƒ) code struct SafeAreaBootcamp: View { var body: some View { Text("Hello, Worl...
Select One:
View Post

[SwiftUI] LazyVGrid()

LazyVGrid() fixed struct GridBootcamp: View { // ๊ทธ๋ฆฌ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” GridItem ๋ฐฐ์—ด์ด ํ•„์š”ํ•˜๋‹ค. let columns: [GridItem] = [ // ํ•„์š”ํ•œ ์ปฌ๋Ÿผ์˜ ์ˆ˜ ๋งŒํผ ๋งŒ๋“ ๋‹ค. GridItem(.fixed(50), spacing: nil, alignment: nil), GridItem(.fixed(75), spacing: nil, alignment: nil), GridItem(.fixed(100), spac...
Select One:
View Post

[SwiftUI] ScrollView()

ScrollView() ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ํ™”๋ฉด์ด ๋„˜์–ด๊ฐ„๋‹ค. struct ScrollViewBootcamp: View { var body: some View { VStack { Rectangle() .frame(height: 300) Rectangle() .frame(height: 300) Rectangle() .frame(height: 300)...
Select One:
View Post

[Swift UI] ForEach()

ForEach() ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ฃจํ”„๋‹ค. ์•„๋ž˜์ฒ˜๋Ÿผ ์ฝ”๋”ฉ์„ ํ•˜๋Š” ๊ฒƒ์€ ๋งค์šฐ ์„ฑ๊ฐ€์‹ ์ผ์ด๋‹ค. struct ForEachBootcamp: View { var body: some View { VStack { Text("ONE") Text("TWO") Text("THREE") } } } ๊ทธ๋ž˜์„œ ForEach๋ฌธ์„ ์‚ฌ์šฉํ•œ๋‹ค. struct ForEachBootcamp...
Select One:
View Post

[SwiftUI] init() & enum

init() & enum init struct InitBootCamp: View { //let backgroundColor: Color = Color.blue //์•„๋ž˜์˜ ๊ฒฝ์šฐ์ฒ˜๋Ÿผ ์ดˆ๊ธฐํ™”๋ฅผ ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ๋Š” ์ดˆ๊ธฐํ™”๋ฅผ ํ•˜์—ฌ์•ผ ํ•œ๋‹ค. let backgroundColor: Color let count: Int let title: String VStack { Text("\(count)") .font(.largeTitle) .foregroundColor(.white) .underline() Text(ti...
Select One:
View Post

[SwiftUI] Spacer()

Spacer() HStack(spacing:nil) { // nil์€ ๊ธฐ๋ณธ๊ฐ’์„ ์˜๋ฏธํ•จ Rectangle() .frame(width:100, height: 100) Spacer() // ๊ฐ€๋Šฅํ•œ ์ตœ๋Œ€์˜ ์˜์—ญ์„ ํ™•๋ณดํ•œ๋‹ค. .frame(height: 10 ) // ์ŠคํŽ˜์ด์„œ์˜ ์˜์—ญ์„ ํ™•์ธํ•ด ๋ณธ๋‹ค. .background(Color.orange) Rectangle() .fill(Color.red) .frame(width:100, height: 100) } .background(Color.blue) Space...
Select One:
View Post

[SwiftUI] Padding()

Padding() Text("Hello,World") .background(Color.yellow) .padding() //ํ…์ŠคํŠธ ์ฃผ๋ฉด์— ์—ฌ์œ ๊ณต๊ฐ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค. .padding(.all, 10) // ์ด๋Ÿฐ์‹์œผ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค. .padding(.leading, 20 ) // ์•ž์ชฝ์— ์ถ”๊ฐ€๋กœ 20์˜ ๊ณต๊ฐ„์„ ๋” ์ค€๋‹ค. .padding(.horizontal, 10 ) //.vertical , // .leading, top, bottom , trailing์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค....
Select One:
View Post

[SwiftUI] Stacks

VStack(), HStack(), ZStack() VStack { // ๊ตฌ์„ฑ์š”์†Œ๋“ค์ด ์ƒํ•˜๋กœ ์Œ“์ธ๋‹ค. HStack { // ๊ตฌ์„ฑ์š”์†Œ๋“ค์ด ์ขŒ์šฐ๋กœ ์Œ“์ธ๋‹ค. ZStack { // ๊ตฌ์„ฑ์š”์†Œ๋“ค์ด ๋ฐ”๋‹ฅ์—์„œ ์ƒ๋ถ€๋กœ ์Œ“์ธ๋‹ค. Rectangle() .fill(Color.red) .frame(width:200, height: 200) Rectangle() .fill(Color.green) .frame(width:150, height: 150) Rectangle() .fill(Color.orange)...
Select One:
View Post

[SwiftUI] background & overlay

background code // background๋„ ์ฝ”๋“œ์˜ ์•„๋žซ์ชฝ๋ถ€ํ„ฐ ์Œ“์ธ๋‹ค. // ์ •ํ™•ํžˆ๋Š” frame์ด ์•„๋žซ์ชฝ์—์„œ ๋ถ€ํ„ฐ ์Œ“์ด๋Š” ๊ฒƒ์ธ๊ฒƒ ๊ฐ™๋‹ค. // ์ด ํ”„๋ ˆ์ž„์— ๋Œ€ํ•œ ๋ฐฐ๊ฒฝ์„ ์ •ํ•ด์ฃผ๋Š” ๊ฒƒ๊ฐ™๋‹ค. Text("Hello,World") .frame(width:100, height:100, alignment:.center) // ์ด๊ฒƒ์€ ํ…์ŠคํŠธ์— ๋Œ€ํ•œ ํ”„๋ ˆ์ž„์ด๋‹ค. .background(Color.red) // ๋นจ๊ฐ•์ƒ‰์œผ๋กœ ๋ฐฐ๊ฒฝ์„ ๋งŒ๋“ ...
Select One:
View Post

[SwiftUI] .frame()

.frame() ์–ด๋–ค ์ข…๋ฅ˜์˜ ์š”์†Œ๋“  ํ”„๋ ˆ์ž„์„ ๊ฐ–๋Š”๋‹ค. ํ…์ŠคํŠธ๋„ ๊ธฐ๋ณธ ํ”„๋ ˆ์ž„์„ ๊ฐ–๋Š”๋‹ค. Code Text("Hello,World") .background(Color.green) // ํ…์ŠคํŠธ ๋ฐฐ๊ฒฝ์ด ๋ณ€ํ™” .frame(width:100, height:100, alignment:.center) // ์ƒˆ๋กœ์šด ํ”„๋ ˆ์ž„ ์„ค์ • .background(Color.red) // ํ”„๋ ˆ์ž„ ์„ค์ • .frame(maxWidth: .infinity, alignment: .center) //...
Select One:
View Post

[SwiftUI] Image()

Image() ์ด๋ฏธ์ง€๋Š” xcode์— ๋ฏธ๋ฆฌ ๋“ฑ๋กํ•ด์•ผํ•œ๋‹ค. Assets ํŒŒ์ผ์— ๋“ฑ๋กํ•œ๋‹ค. ์˜ˆ) SampleImage ์ฐธ๊ณ ) ๋ญ”๊ฐ€ ์—๋Ÿฌ๊ฐ€ ์ƒ๊ธฐ๋ฉด Clean build folder๋ฅผ ์ด์šฉํ•œ๋‹ค. Command+Shift+K Code Image("SampleImage") // ์–ด์Ž—ํŒŒ์ผ์— ๋“ฑ๋ก๋œ ์ด๋ฆ„์„ ์‚ฌ์šฉํ•œ๋‹ค. .resizable() .aspectRatio(contentMode: .fill) .frame(width:300,height:200) .clipped() // ์œ„...
Select One:
View Post

[SwiftUI] System Icons

System Icons SF Symbols ๊ตฌ๊ธ€์—์„œ ๊ฒ€์ƒ‰ํ•˜์—ฌ ์„ค์น˜ํ•œ๋‹ค. ์˜ˆ struct IconsBootcamp: View { var body: some View { Image(systemName: "heart.fill") .font(.system(size:50)) .foregroundColor(.green) // color ์„ค์ • .frame(width:300, height:300) //font๋ฅผ ์ด์šฉํ•˜์—ฌ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๊ณ  //frame์„ ์ด์šฉํ•˜์—ฌ ํฌ๊ธฐ๋ฅผ...
Select One:
View Post

[SwiftUI] Gradients

Gradients ์˜ˆ struct GradientsSample: View { var body: some view { RoundedRectangle(cornerRadius: 25.0) .fill( //Color.red // gradient๋ฅผ ํƒ€์ดํ•‘ํ•˜๋ฉด ์–ป์„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ ์ค‘ ์„ ํƒ // startPoint์™€ EndPoint๋ฅผ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ LinearGradient( // ์„ ํ˜• ๊ทธ๋ž˜๋””์–ธํŠธ...
Select One:
View Post

[SwiftUI] Color

Color ์˜ˆ RoundedRectangle(cornerRadius: 25.0 ) .frame(width: 300, height: 200) .shadow(radius: 10) // ์‰๋„์šฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. .shadow(color:Color.red, radius:10, x:20, y:20) .shadow(color:Color("CustomColor").opacity(0.3), radius:10 , x:-20, y:-20) // ํˆฌ๋ช…๋„๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. .fill(Color.red) // ๋ฏธ๋ฆฌ ์„ค...
Select One:
View Post

[SwiftUI]Shapes

Shapes Component Circle() // ์› Ellipse() // ํƒ€์› Capsule(style: .continuous) // ์บก์Šํ˜•ํƒœ // . continuous -> ์ข€๋” ์•ฝ์ฒ˜๋Ÿผ ์ƒ๊น€ // . circular -> ์ข€๋” ๋‘ฅ๊ธ€๋‹ค. Rectangle() //์‚ฌ๊ฐํ˜• RoundedRectangle(cornerRadius:10) // ๋‘ฅ๊ทผ ๋ชจ์„œ๋ฆฌ ์‚ฌ๊ฐํ˜• modifiers .fill(Color.blue) // ํŒŒ๋ž€์ƒ‰์œผ๋กœ ์ฑ„์šด๋‹ค. .foregroundColor(.pink) // ๊ธฐ๋ณธ...
Select One:
View Post

[SwiftUI] Text()

Text() ์šฐ์ธก inspector์—์„œ modifiers์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค. ์ต์ˆ™ํ•ด ์ง€๋ฉด ์ง์ ‘ ์ฝ”๋”ฉ์„ ํ•œ๋‹ค. Text("Hello, World") // ์ด๊ฒƒ์€ ์ปดํฌ๋„ŒํŠธ ์ด๊ณ  .font(.title) // ์ด๊ฒƒ์€ ๋ชจ๋””ํŒŒ์ด์–ด ๋‹ค. Modifiers .font(.body) // ์ด๊ฒฝ์šฐ๋Š” ํฐํŠธ์˜ ํฌ๊ธฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋‹ค. .font(.system(size: 24, weight: .semibold, design: .monospace )) // ํฐํŠธ...
Select One:
View Post

AppData ์ ‘๊ทผ

ํŒŒ์ผํƒ์ƒ‰๊ธฐ ๊ฒฝ๋กœ์ฐฝ์— %appdata%๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.
Select One:
View Post

[Swift] throws

์—๋Ÿฌ์ฒ˜๋ฆฌ๋Š” 3๋‹จ๊ณ„๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. ์—๋Ÿฌ๋ฅผ ์ •์˜ํ•œ๋‹ค. ๋ฐœ์ƒํ•œ ์—๋Ÿฌ๋ฅผ ์•Œ๋ ค์ค€๋‹ค(์ •๋ณด๋ฅผ ๋˜์ง„๋‹ค.) ๋ฐ›์€ ์—๋Ÿฌ๋ฅผ ์ฒ˜๋ฆฌํ•œ๋‹ค. 1. ์—๋Ÿฌ๋ฅผ ์ •์˜ํ•œ๋‹ค. enum์œผ๋กœ ์ •ํ•œ๋‹ค. enum myError: Error { case tooMany case tooSmall } 2. ๋ฐœ์ƒํ•œ ์—๋Ÿฌ๋ฅผ ์•Œ๋ ค์ค€๋‹ค(๋˜์ง„๋‹ค) func myAge(_ age: Int) throw -> Int { var text = "" guard age > 20 els...
Select One:

Loading More Content

Back to DevDojo