Skip to content

Instantly share code, notes, and snippets.

@propertyWrapper
public struct DzUserDefault<Value> {
public let key: String
public let defaultValue: Value
public var storage: UserDefaults = .standard
public var wrappedValue: Value {
get {
return storage.object(forKey: key) as? Value ?? defaultValue
}
@kimjiwook
kimjiwook / SwiftUI_Breathe_App_Sample.swift
Created June 19, 2023 12:35
SwiftUI_Breathe_App_Sample
import SwiftUI
// 애플워치 심호흡 애니메이션 따라하기.
struct Breathe_App: View {
@State var isAnimation:Bool = true
var body: some View {
ZStack {
@kimjiwook
kimjiwook / SwiftUI_cornerRadius_Sample003.swift
Created May 22, 2023 08:51
SwiftUI_cornerRadius_Sample003.swift
struct ContentView3: View {
var body: some View {
HStack {
// 위쪽만
Rectangle()
.overlay{
Image(systemName: "person.crop.circle")
.resizable()
.frame(width: 100, height: 100)
}
@kimjiwook
kimjiwook / SwiftUI_cornerRadius_Sample002.swift
Created May 22, 2023 08:50
SwiftUI_cornerRadius_Sample002.swift
struct ContentView2: View {
var body: some View {
HStack {
// 1. 라운드 지정된 값 적용
Rectangle()
.overlay{
Image(systemName: "person.crop.circle")
.resizable()
.frame(width: 100, height: 100)
}
@kimjiwook
kimjiwook / SwiftUI_cornerRadius_Sample001.swift
Created May 22, 2023 08:50
SwiftUI_cornerRadius_Sample001.swift
struct ContentView1: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
.padding()
.background(.red)
@kimjiwook
kimjiwook / SwiftUI_Padding_Sample003.swift
Created April 16, 2023 05:55
SwiftUI_Padding_Sample003
struct ContentView3: View {
var body: some View {
VStack {
// 패딩 X
Text("Hello, world!")
.border(Color.black, width: 1)
// 패딩 .all
Text("Hello, world!")
.padding(.all, 8)
@kimjiwook
kimjiwook / SwiftUI_Padding_Sample002.swift
Created April 16, 2023 05:55
SwiftUI_Padding_Sample002
struct ContentView2: View {
var body: some View {
VStack {
// 패딩 X
Text("Hello, world!")
.border(Color.black, width: 1)
// 패딩 EdgeInsets 활용
Text("Hello, world!")
.padding(EdgeInsets(top: 2, leading: 6, bottom: 8, trailing: 10))
.border(Color.black, width: 1)
@kimjiwook
kimjiwook / SwiftUI_Padding_Sample001.swift
Created April 16, 2023 05:54
SwiftUI_Padding_Sample001
struct ContentView: View {
var body: some View {
VStack {
// 패딩 X
Text("Hello, world!")
.border(Color.black, width: 1)
// 패딩 기본값
Text("Hello, world!")
.padding() // 텍스트 필드의 패딩값 주기
.border(Color.black, width: 1)
@kimjiwook
kimjiwook / DocScan2_Sample004.swift
Last active April 16, 2023 04:25
DocScan2_Sample004
// 타이머 관련 변수선언 (애니메이션 효과를 위해)
let timer = Timer.publish(every: 1.0, on: .main, in: .common).autoconnect()
@State var value = 0.0
(..... 생략 .....)
// 이미지 그리고 위에 overlay 를 통한 텍스트 위치 표기해주기.
Image(uiImage: image)
.resizable()
.scaledToFit()
@kimjiwook
kimjiwook / DocScan2_Sample003.swift
Created April 16, 2023 04:19
DocScan2_Sample003
// TextView Scan관련
extension ContentVM {
// import Vision // Text 뽑아오는게 있내 <-- 필수
// 1. Text 빼오는거 샘플
func detectText(_ image: UIImage) {
guard let image = image.cgImage else {
print("Invalid image")
return
}