iOSDC Japan 2022 Day2 14:00~ Unconference トーク
KyomeiOSDC Japan 2022 - Unconference2022/09/12iOSͷΟδΣοτͰೣΒ͍ͤͨ
View Slide
iOSDC Japan 2022 - Unconference#iosdc #unconferenceࣗݾհIUUQTLZPNFJP,ZPNF,ZPNFTVLFmacOS͚ͷϢʔςΟϦςΟΞϓϦ։ൃऀʢझຯ݉෭ۀʣϝχϡʔόʔৗறܕΞϓϦɺApp Extension ͕ಘҙීஈαΠϘζͰ kintoneϞόΠϧ ։ൃ͍ͯ͠·͢ʂ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?RunCatmacOS ͚ͷϝχϡʔόʔৗறܕΞϓϦೣͷΔεϐʔυͰ CPU ෛՙ͕Θ͔Δ ΞΫςΟϏςΟɾΠϯδέʔλʔ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?macOS൛ͷRunCat CAKeyframeAnimation ΛͬͯύϥύϥອըͷཁྖͰΞχϝʔγϣϯ͍ͯ͠ΔʢແݶϧʔϓʣఆظతʹCPUෛՙΛऔಘͯ͠ɺͦͷʹج͍ͮͯΞχϝʔγϣϯͷspeed Λߋ৽͍ͯ͠Δcat-0 cat-1 cat-2 cat-3 cat-4Speed
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?speed Λߋ৽͢ΔࡍʹΞχϝʔγϣϯ͕Ϧηοτ͞ΕΔͷͰɺ ରࡦ͠ͳ͍ͱΞχϝʔγϣϯ͕ΨΫΨΫͯ͠͠·͏☝︎͜Μͳײ͡
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?speed Λߋ৽͢ΔࡍʹΞχϝʔγϣϯ͕Ϧηοτ͞ΕΔͷͰɺ ରࡦ͠ͳ͍ͱΞχϝʔγϣϯ͕ΨΫΨΫͯ͠͠·͏cat-0 cat-1 cat-2 cat-3 cat-4Speed มߋ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?speed Λߋ৽͢ΔࡍʹΞχϝʔγϣϯ͕Ϧηοτ͞ΕΔͷͰɺ ରࡦ͠ͳ͍ͱΞχϝʔγϣϯ͕ΨΫΨΫͯ͠͠·͏cat-0 cat-1 cat-2 cat-3 cat-4Speed มߋ☝︎࣍ͷΞχϝʔγϣϯ cat-3 ͔Β ࢝Ίͳ͍ͱεϜʔζʹͳΒͳ͍
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?speed Λߋ৽͢ΔࡍʹΞχϝʔγϣϯ͕Ϧηοτ͞ΕΔͷͰɺ ରࡦ͠ͳ͍ͱΞχϝʔγϣϯ͕ΨΫΨΫͯ͠͠·͏γʔϜϨεʹΓସ͑ΔͨΊɺߋ৽લʹ CALayer ͷ timeOffset ͱbeginTime Λ੍ޚ్ͯ͠த͔ΒΞχϝʔγϣϯ͕࢝·ΔΑ͏ʹ͢Δ☝︎cat-3 ͔Β࢝·Γ cat-2 ͰऴΘΔΞχϝʹ͢Δcat-3 cat-4 cat-0 cat-1 cat-2
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWhat’s RunCat?͜ͷΑ͏ͳεϐʔυ్͕தͰมԽ͢ΔແݶϧʔϓͷίϚૹΓ ΞχϝʔγϣϯΛ࣮ݱͰ͖Δ࠷దखஈ͕ CAKeyframeAnimationCore Animation ͍͢͝ʂ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceؓٳ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceiOSͰೣΒ͍ͤͨ2020ͷKyomeࢯ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWidgetKit ग़ͨ͠ͳΜ͔Ͱ͖ͦ͏2020ͷKyomeࢯ※ 2020 iOS 14 ͕ൃද͞Ε WidgetKit ͕ಋೖ͞Ε·ͨ͠ɻ
iOSDC Japan 2022 - Unconference#iosdc #unconferencevs WidgetKit
iOSDC Japan 2022 - Unconference#iosdc #unconferenceઈରʹΞχϝʔγϣϯͤͨ͘͞ͳ͍ 74 Կͱͯ͠ΟδΣοτͰೣΒ͍ͤͨɾ
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZͱΓ͋͑ͣૉʹ Ξχϝʔγϣϯࢼͯ͠ΈΔ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceTry 1: ͱΓ͋͑ͣૉʹΞχϝʔγϣϯࢼͯ͠ΈΔin Appstruct RotateItemView: View {@State var flag: Bool = falsevar body: some View {Image(systemName: "paperplane").resizable().frame(width: 100, height: 100, alignment: .center).rotationEffect(Angle(degrees: flag ? 0 : 360)).animation(Animation.linear(duration: 2).repeatForever(autoreverses: false),value: flag).onAppear {flag.toggle()}}}
iOSDC Japan 2022 - Unconference#iosdc #unconferenceTry 1: ͱΓ͋͑ͣૉʹΞχϝʔγϣϯࢼͯ͠ΈΔin Widgetstruct RotateItemView: View {@State var flag: Bool = falsevar body: some View {Image(systemName: "paperplane").resizable().frame(width: 100, height: 100, alignment: .center).rotationEffect(Angle(degrees: flag ? 0 : 360)).animation(Animation.linear(duration: 2).repeatForever(autoreverses: false),value: flag).onAppear {flag.toggle()}}}Ξχϝʔγϣϯ͠ͳ͍💦
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZ5JNFSΛͬͯίϚૹΓͯ͠ΈΔ
iOSDC Japan 2022 - Unconference#iosdc #unconferencestruct CatTimerView: View {@State var catIndex: Int = 0let timer = Timer.publish(every: 0.1, on: .main, in: .default).autoconnect()var body: some View {Image("cat-\(catIndex)").onReceive(timer) { _ incatIndex = (catIndex + 1) % 5}.padding()}}Try 2: TimerΛͬͯίϚૹΓͯ͠ΈΔin App
iOSDC Japan 2022 - Unconference#iosdc #unconferencestruct CatTimerView: View {@State var catIndex: Int = 0let timer = Timer.publish(every: 0.1, on: .main, in: .default).autoconnect()var body: some View {Image("cat-\(catIndex)").onReceive(timer) { _ incatIndex = (catIndex + 1) % 5}.padding()}}Try 2: TimerΛͬͯίϚૹΓͯ͠ΈΔin WidgetΓಈ͔ͳ͍💧
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZͦ͏ͩ6*,JUʹཔΖ͏ʂ
iOSDC Japan 2022 - Unconference#iosdc #unconferencevar animatedCatImage: Image? {if let uiImage = UIImage.animatedImageNamed("cat-", duration: 1) {return Image(uiImage: uiImage)}return nil}Try 3: ͦ͏ͩ UIKit ʹཔΖ͏ʂin AppUIImage.animatedImageNamed(_:duration:) Λ͑ɺ ࿈൪ʹͳ͍ͬͯΔϑΝΠϧ໊ͷը૾ΛΞχϝʔγϣϯԽ ͞ΕͨҰͭͷ UIImageʹͰ͖Δ͕…UIImageView ͩͱಈ͚͘Ͳ SwiftUIͷImageʹೖΕΔͱಈ͔ͳ͍
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZ6*7JFX3FQSFTFOUBCMFͰͲ͏ͩʂ
iOSDC Japan 2022 - Unconference#iosdc #unconferencestruct CatRepView: UIViewRepresentable {typealias UIViewType = UIImageViewlet uiImage: UIImage?init() {uiImage = UIImage.animatedImageNamed("cat-", duration: 1)}func makeUIView(context: Context) -> UIImageView {let imageView = UIImageView(image: uiImage)imageView.contentMode = .scaleAspectFitreturn imageView}func updateUIView(_ uiView: UIImageView, context: Context) {}}Try 4: UIViewRepresentable ͰͲ͏ͩʂ࣌ͷදࣔΛ࠶ݱͨ͠ͷ❗͔ͯɺφχίϨ!!UIKit ༝དྷͷ View ΟδΣοτͷதͰແޮ
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZ(*'ΛಡΈࠐΜͰΈΔ
iOSDC Japan 2022 - Unconference#iosdc #unconferencevar catGIFImage: Image? {if let asset = NSDataAsset(name: "runcat-gif"),let uiImage = UIImage(data: asset.data) {return Image(uiImage: uiImage)}return nil}Try 5: GIFΛಡΈࠐΜͰΈΔin AppͦͦΟδΣοτ͡Όͳͯ͘ಈ͔ͳ͍
iOSDC Japan 2022 - Unconference#iosdc #unconferenceͦͯ͠ࢸͬͨKyomeࢯͷ݁
iOSDC Japan 2022 - Unconference#iosdc #unconference
iOSDC Japan 2022 - Unconference#iosdc #unconference࣌ྲྀΕ݄̎̌̎̎̒
iOSDC Japan 2022 - Unconference#iosdc #unconferenceWWDC 2022 ʹͯ Live Activities ൃද
iOSDC Japan 2022 - Unconference#iosdc #unconferenceLive Activitiesref: AppleɺiOS 16Ͱಋೖ͞ΕΔڞ༗ͱίϛϡχέʔγϣϯͷͨΊͷ৽͍͠ํ๏Λൃද - Apple (ຊ)https://www.apple.com/jp/newsroom/2022/06/apple-unveils-new-ways-to-share-and-communicate-in-ios-16/
iOSDC Japan 2022 - Unconference#iosdc #unconferenceLive Activitiesref: Keynote (ASL) - WWDC22 - Videos - Apple Developer. https://developer.apple.com/videos/play/wwdc2022/111/
iOSDC Japan 2022 - Unconference#iosdc #unconferenceࠓΞχϝʔγϣϯͯ͠ͳ͔͔ͬͨ⁉︎2022ͷKyomeࢯ⁉
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZ-JWF"DUJWJUJFTΛͬͯΈΔ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceTry 6: Live Activities ΛͬͯΈΔLive Activities ActivityKit Framework Λ࣮ͬͯ͢Δ ActivityKit Xcode 14 beta 4~6 Ͱ͑ΔXcode 14 RC ʹೖ͍ͬͯͳ͍ૣࢼ͍ͯ͠ΔਓͷهࣄGitHubͷιʔε*͕͋ΔͷͰ࣮ͦΜͳʹ͘͠ͳ͍* Create Live Activities With ActivityKit on iOS 16 | by Batikan Sosun | Aug, 2022 | Better Programming https://betterprogramming.pub/create-live-activities-with-activitykit-on-ios-16-beta-4766a347035b
iOSDC Japan 2022 - Unconference#iosdc #unconferenceTry 6: Live Activities ΛͬͯΈΔࢼͯ͠Θ͔ͬͨ͜ͱLive Activities جຊతʹΟδΣοτͱҰॹ ϩοΫεΫϦʔϯʹදࣔͰ͖ΔΟδΣοτͱ͍͏ײ͡ΓΞχϝʔγϣϯͰ͖ͳ͍😫ं͕ಈ͍͍ͯΔΑ͏ʹݟ͑ͨͷɺSliderͷϊϒͷը૾Λม͍͚͑ͯͨͩ ߋ৽࣌ʹϊϒͷҠಈΞχϝʔγϣϯ͕࣮ߦ͞ΕΔλΠϚʔ Text(date: Date, style: Text.DateStyle) Λ࣮͑Ͱ͖Δ͔͠ɺiOS 14͔Β͜Ε͋ͬͨʢΒͳ͔ͬͨ..ʣ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceͦͯ͠ࢸͬͨKyomeࢯͷ݁վΊ
iOSDC Japan 2022 - Unconference#iosdc #unconference͔͠͠KyomeࢯʹిྲྀΔʔʔʂ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceॴḨɺRunCat ̑ຕͷ੩ࢭըΛ ίϚૹΓ͍ͯ͠Δ͚ͩ… ͳΒ
iOSDC Japan 2022 - Unconference#iosdc #unconference5SZλΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτ Ͱࠩ͠ସ͑Ε͍͍͡Όͳ͍
iOSDC Japan 2022 - Unconference#iosdc #unconferenceTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍λΠϚʔΛදࣔͨ͠ΟδΣοτೣϑΥϯτ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceCalligraphr ͱ͍͏ϑΥϯτΛࣗ࡞Ͱ͖Δ αʔϏεΛͬͯೣϑΥϯτΛ࡞Δೣ̑ϑϨʔϜͳͷͰɺ 0~4ͱ5~9ͷ̎पࢦఆ͢Δग़དྷ্͕ͬͨOpenTypeϑΥϯτΛ ϓϩδΣΫτʹऔΓࠐΉTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍ref: Calligraphr. https://www.calligraphr.com/en/webapp/app_home/?/
iOSDC Japan 2022 - Unconference#iosdc #unconferencestruct ContentView: View {var body: some View {Text(Date(), style: .timer).font(.custom("Runningcat-Regular", size: 150))}}in AppͱΓ͋͑ͣී௨ͷSwiftUI AppͳΒػೳͨ͠ʂͳΜ͔ΧϫΠΠTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍❗
iOSDC Japan 2022 - Unconference#iosdc #unconference͚ͩ͘͜͜Γൈ͖͍ͨTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍
iOSDC Japan 2022 - Unconference#iosdc #unconferencestruct ContentView: View {var body: some View {Text(Date(), style: .timer).lineLimit(1).font(.custom("Runningcat-Regular", size: 200)).fixedSize(horizontal: true, vertical: false).frame(width: 120, alignment: .trailing).clipped()}}in AppTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍.lineLimit(1) ͱ .fixedSize() ͰվߦΛڐ͞ͳ͍Α͏ʹ͢Δ.frame(width: 120, alignment: .trailing) Ͱ෯ΛೣҰඖʹͭͭ͠ɺTextΛӈدͤʹ͢Δ.clipped() Ͱ༨ͳೣΛফ͢
iOSDC Japan 2022 - Unconference#iosdc #unconferencestruct ContentView: View {var body: some View {Text(Date(), style: .timer).lineLimit(1).font(.custom("Runningcat-Regular", size: 200)).fixedSize(horizontal: true, vertical: false).frame(width: 120, alignment: .trailing).clipped()}}in WidgetTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍ΟδΣοτͩͱ Text(Date(), style: .timer) ͱ .fixedSize()ͷ૬ੑ͕ѱ͍Β͘͠ɺText͕ফ͑ͯ͠·͏ͱʃ͓ʃ͠ʃͯʃͨʃΑʃ͓ʃ͓ʃ͓ʃʂ💢
iOSDC Japan 2022 - Unconference#iosdc #unconferenceࢼߦࡨޡͨ݁͠Ռ
iOSDC Japan 2022 - Unconference#iosdc #unconference͍ͭʹΟδΣοτͰೣಈ͖·ͨ͠ʂʂTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍Γ·ͨ͠🎉 ༏উ🏆👑
iOSDC Japan 2022 - Unconference#iosdc #unconferencein WidgetTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍.fixedSize() Group ͰแΜͰ͔Β͑༗ޮ.clipped() ͞Βʹ Group ͰแΜͰ͔Β͑༗ޮvar body: some View {Group {Group {Text(Date(), style: .timer).lineLimit(1).truncationMode(.head).font(.custom("Runningcat-Regular", size: 120)).frame(width: 200)}.fixedSize()}.frame(width: 90, alignment: .trailing).clipped()}
iOSDC Japan 2022 - Unconference#iosdc #unconferencevar body: some View {Group {Group {Text(Date(), style: .timer).lineLimit(1).truncationMode(.head).font(.custom("Runningcat-Regular", size: 120)).frame(width: 200)}.fixedSize()}.frame(width: 90, alignment: .trailing).clipped()}in WidgetTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍.truncationMode(.head) Ͱ෯͕Γͳ͍ͱ͖ઌ಄͕ ʮ…ʯͰলུ͞ΕΔΑ͏ʹ͓ͯ͘͜͠ͱ͕ॏཁলུͭͭ͠෯Λݻఆͤ͞ΔͨΊʹɺframe(width: 200) Ͱ ೋจࣈͷ෯Λࢦఆ͢Δ
iOSDC Japan 2022 - Unconference#iosdc #unconferencevar body: some View {Group {Group {Text(Date(), style: .timer).lineLimit(1).truncationMode(.head).font(.custom("Runningcat-Regular", size: 120)).frame(width: 200)}.fixedSize()}.frame(width: 90, alignment: .trailing).clipped()}in WidgetTry 7: λΠϚʔ͕ಈ͔ͤΔͳΒೣϑΥϯτͰࠩ͠ସ͑Ε͍͍͡Όͳ͍.clipped() ͢Δલʹ .frame(width: 90, alignment: .trailing) Ͱද͍ࣔͤͨ͞ೣҰඖͷ෯Λ֬อ͢Δ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceRunCatͱͯ͠ͷ՝
iOSDC Japan 2022 - Unconference#iosdc #unconferenceRunCatͱͯ͠ͷ՝Έ্ɺίϚૹΓͷִؒ̍ඵͰݻఆԿ͔ͷঢ়ଶʹԠͯ͡εϐʔυΛม͑Δͱ͍͏͜ͱͰ͖ͳ͍
iOSDC Japan 2022 - Unconference#iosdc #unconferenceRunCatͱͯ͠ͷ՝Έ্ɺίϚૹΓͷִؒ̍ඵͰݻఆԿ͔ͷঢ়ଶʹԠͯ͡εϐʔυΛม͑Δͱ͍͏͜ͱͰ͖ͳ͍͔ͯ͜Ε͡ΌΞχϝʔγϣϯ ͱݴ͑ͳ͘ͳ͍ʁ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceRunCatͱͯ͠ͷ՝Έ্ɺίϚૹΓͷִؒ̍ඵͰݻఆԿ͔ͷঢ়ଶʹԠͯ͡εϐʔυΛม͑Δͱ͍͏͜ͱͰ͖ͳ͍͔ͯ͜Ε͡ΌΞχϝʔγϣϯ ͱݴ͑ͳ͘ͳ͍ʁ͏ͬͤ͐ʂ💢
iOSDC Japan 2022 - Unconference#iosdc #unconferenceRunCatͱͯ͠ͷ՝Έ্ɺίϚૹΓͷִؒ̍ඵͰݻఆԿ͔ͷঢ়ଶʹԠͯ͡εϐʔυΛม͑Δͱ͍͏͜ͱͰ͖ͳ͍ঢ়ଶʹԠͯ͡ೣҎ֎ͷϥϯφʔʹΓସ͑Δ͍ͬͯΔίϚΞχϝ͚ͩͰͳ͘า͍͍ͯΔίϚΞχϝ༻ҙ͢Δ
iOSDC Japan 2022 - Unconference#iosdc #unconferenceiOSͷΟδΣοτͰೣΒ͍ͤͨThank you!ઓ͍·ͩଓ͘…