Skip to content

SwiftUIプロジェクトで使用できる一般的な UIViewControllerRepresentable コードを含むリポジトリを作成しました。

License

Notifications You must be signed in to change notification settings

mszmagic/SwiftUICompatible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUICompatible

image

SwiftUI は新しいフレームワークであるので、フィーチャー UIKit の幾らかを欠いています。そららフィーチャー UIKit を活用する為には、UIViewControllerRepresentable を使用しなければなりません。

頻出する UIViewControllerRepresentable のコードを蓄積するレポジトリを作成したので、SwiftUI プロジェクトに活用してください。

ぜひお気軽に、作成されたコードをこのレポジトリに追加してください。

含まれているクラス UIViewControllerRepresentable

使用方法

- コードをブラウズし、自身のプロジェクトにコピーアンドペーストすることができます。

- Swift Package Manager

または、Swift Package Manager を使用して自身のプロジェクトにコードを挿入することができます。iOS 14のみに対応しているため、Swift Package Manager には PhotoPicker が含まれないことにご注意ください。

  1. Xcode内からプロジェクトを開く
  2. 上部のシステムバーの"File"をクリック
  3. "Swift Packages"をクリック、次いで"Add package dependency…"をクリック
  4. 以下のURLをペースト:https://github.com/mszmagic/SwiftUICompatible.git
  5. Version: Up to Next Major 1.0.1 <
  6. "Next"をクリック
  7. "Done"をクリック。
import SwiftUICompatible

struct ContentView: View {
    
    @State private var showPreview = false
    
    var body: some View {
        Button(action: {
            self.showPreview = true
        }){
            Text("表示")
        }
        .sheet(isPresented: $showPreview, content: {
             SafariView(url: URL(string: "https://github.com/mszmagic/SwiftUICompatible")!)
        })
    }
    
}

About

SwiftUIプロジェクトで使用できる一般的な UIViewControllerRepresentable コードを含むリポジトリを作成しました。

Topics

Resources

License

Stars

Watchers

Forks

Languages