Skip to content

Instantly share code, notes, and snippets.

View donchan922's full-sized avatar
🐶
I'm fine.

donchan922 donchan922

🐶
I'm fine.
View GitHub Profile
@donchan922
donchan922 / ContentView.swift
Created April 18, 2020 05:40
SwiftUIでCore Dataを使ったToDoアプリのサンプルコードその2
import SwiftUI
import CoreData
extension UIApplication {
func endEditing() {
sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
struct ContentView: View {
@donchan922
donchan922 / ContentView.swift
Created April 16, 2020 12:11
SwiftUIでグラデーションを使うサンプル
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
LinearGradient(gradient: .init(colors: [.yellow, .green]), startPoint: .top, endPoint: .bottom)
GeometryReader{ reader in
Button(action: {
}) {
import SwiftUI
import GoogleMobileAds
struct AdView: UIViewRepresentable {
func makeUIView(context: Context) -> GADBannerView {
let banner = GADBannerView(adSize: kGADAdSizeBanner)
// 以下は、バナー広告向けのテスト専用広告ユニットIDです。自身の広告ユニットIDと置き換えてください。
banner.adUnitID = "ca-app-pub-3940256099942544/2934735716"
banner.rootViewController = UIApplication.shared.windows.first?.rootViewController
banner.load(GADRequest())
import UIKit
// import文を追加する
import GoogleMobileAds
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- Key: GADApplicationIdentifier
- Type: String
- Value: ca-app-pub-xxx
$ pod install --repo-update
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'swift-demo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for swift-demo
pod 'Google-Mobile-Ads-SDK'
$ pod init
$ sudo gem install cocoapods
- Xcode 11.4
- Swift 5.2