SlideShare a Scribd company logo
1 of 97
Download to read offline
Accessibility APIs
navigationBarTitle(_:)
edgesIgnoringSafeArea(_:)
colorScheme(_:)
contextMenu(_:)
navigationBarItems(_:)
Drag & Drop UTI (String)
navigationTitle(_:)


navigationBarTitleDisplayMode(_:)
ignoresSafeArea(_:edges:)
preferredColorScheme(_:)
contextMenu(menuItems:)
toolbar(content:)
Drag & Drop UTI (UTType)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


...


}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


...


}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


...


}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)")


func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


...


}


@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)


extension View {


func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibilityLabel(_ label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibilityValue(_ value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibilityHint(_ hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


...


}
min(number1, number2)


zip(sequence1, sequence2)
min(number1, number2)


zip(sequence1, sequence2)
min(number1, number2)


zip(sequence1, sequence2)
UInt32(someUInt16number)


Int64(someInt8number)
min(number1, number2)


zip(sequence1, sequence2)
UInt16(truncating: NSNumber(value: UInt32.max)) // 4294967295 -> 65535


UInt16(bigEndian: 123) // 123 -> 31488
UInt32(someUInt16number)


Int64(someInt8number)
min(number1, number2)


zip(sequence1, sequence2)
UInt16(truncating: NSNumber(value: UInt32.max)) // 4294967295 -> 65535


UInt16(bigEndian: 123) // 123 -> 31488
UInt32(someUInt16number)


Int64(someInt8number)
min(number1, number2)


zip(sequence1, sequence2)
func trimmedPath(from: CGFloat, to: CGFloat) -> Path


func move(to p: CGPoint)
UInt16(truncating: NSNumber(value: UInt32.max)) // 4294967295 -> 65535


UInt16(bigEndian: 123) // 123 -> 31488
UInt32(someUInt16number)


Int64(someInt8number)
func addSubview(_ view: UIView)


func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View


func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
func addSubview(_ view: UIView)


func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View


func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
func addSubview(_ view: UIView)


func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View


func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
func add(Subview view: UIView)
func addSubview(_ view: UIView)


func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View


func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
⛔
func add(Subview view: UIView)
func addSubview(_ view: UIView)


func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View


func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibilityLabel(_ label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibilityValue(_ value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibilityHint(_ hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
✅
func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>


func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier>
⛔
func add(Subview view: UIView)
Slider(value: $opacity) { Text("Slider") }


.accessibilityLabel("Opacity slider")


.accessibilityAction(.escape) { opacity = 0.0 }


.accessibilityAction(.magicTap) { opacity = 1.0 }


.accessibilityAdjustableAction { direction in


switch direction {


case .increment: opacity += 0.05


case .decrement: opacity -= 0.05


default: break


}


}
Slider(value: $opacity) { Text("Slider") }


.accessibilityLabel("Opacity slider")


.accessibilityAction(.escape) { opacity = 0.0 }


.accessibilityAction(.magicTap) { opacity = 1.0 }


.accessibilityAdjustableAction { direction in


switch direction {


case .increment: opacity += 0.05


case .decrement: opacity -= 0.05


default: break


}


}
Slider(value: $opacity) { Text("Slider") }


.accessibilityLabel("Opacity slider")


.accessibilityAction(.escape) { opacity = 0.0 }


.accessibilityAction(.magicTap) { opacity = 1.0 }


.accessibilityAdjustableAction { direction in


switch direction {


case .increment: opacity += 0.05


case .decrement: opacity -= 0.05


default: break


}


}
Slider(value: $opacity) { Text("Slider") }


.accessibilityLabel("Opacity slider")


.accessibilityAction(.escape) { opacity = 0.0 }


.accessibilityAction(.magicTap) { opacity = 1.0 }


.accessibilityAdjustableAction { direction in


switch direction {


case .increment: opacity += 0.05


case .decrement: opacity -= 0.05


default: break


}


}
Image(decorative: "SwiftUI")


.opacity(opacity)


Text("SwiftUI Logo Image")

.font(.caption)


.opacity(opacity)


.onTapGesture { opacity += 0.1 }

.accessibilityValue("Opacity (opacity, specifier: "%.2f")")


.accessibilityAddTraits(.isButton)


.accessibilityScrollAction { (edge) in


switch edge {


case .top: opacity -= 0.5


case .bottom: opacity += 0.5


case .leading: opacity -= 0.2


case .trailing: opacity += 0.2


}


}
Image(decorative: "SwiftUI")


.opacity(opacity)


Text("SwiftUI Logo Image")

.font(.caption)


.opacity(opacity)


.onTapGesture { opacity += 0.1 }

.accessibilityValue("Opacity (opacity, specifier: "%.2f")")


.accessibilityAddTraits(.isButton)


.accessibilityScrollAction { (edge) in


switch edge {


case .top: opacity -= 0.5


case .bottom: opacity += 0.5


case .leading: opacity -= 0.2


case .trailing: opacity += 0.2


}


}
Image(decorative: "SwiftUI")


.opacity(opacity)


Text("SwiftUI Logo Image")

.font(.caption)


.opacity(opacity)


.onTapGesture { opacity += 0.1 }

.accessibilityValue("Opacity (opacity)")


.accessibilityAddTraits(.isButton)


.accessibilityScrollAction { (edge) in


switch edge {


case .top: opacity -= 0.5


case .bottom: opacity += 0.5


case .leading: opacity -= 0.2


case .trailing: opacity += 0.2


}


}
Image(decorative: "SwiftUI")


.opacity(opacity)


Text("SwiftUI Logo Image")

.font(.caption)


.opacity(opacity)


.onTapGesture { opacity += 0.1 }

.accessibilityValue("Opacity (opacity, specifier: "%.2f")")


.accessibilityAddTraits(.isButton)


.accessibilityScrollAction { (edge) in


switch edge {


case .top: opacity -= 0.5


case .bottom: opacity += 0.5


case .leading: opacity -= 0.2


case .trailing: opacity += 0.2


}


}
Image(decorative: "SwiftUI")


.opacity(opacity)


Text("SwiftUI Logo Image")

.font(.caption)


.opacity(opacity)


.onTapGesture { opacity += 0.1 }

.accessibilityValue("Opacity (opacity, specifier: "%.2f")")


.accessibilityAddTraits(.isButton)


.accessibilityScrollAction { (edge) in


switch edge {


case .top: opacity -= 0.5


case .bottom: opacity += 0.5


case .leading: opacity -= 0.2


case .trailing: opacity += 0.2


}


}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View


}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


extension View {


func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View


}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.")


extension View {


func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View


}


@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)


extension View {


func ignoresSafeArea(_ regions: SafeAreaRegions = .all, edges: Edge.Set = .all) -> some View


}
[ ignore (.all) ][ 미적용 ]
[ ignore (.all) ][ 미적용 ] [ ignore (.keyboard) ]
[ ignore (.all) ] [ ignore (.container) ][ 미적용 ] [ ignore (.keyboard) ]
[ .top ][ 미적용 ]
[ .top ][ 미적용 ] [ .top, .bottom ]
[ .top ] [ .bottom ][ 미적용 ] [ .top, .bottom ]
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


func colorScheme(_ colorScheme: ColorScheme) -> some View


}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


func colorScheme(_ colorScheme: ColorScheme) -> some View


}
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


func colorScheme(_ colorScheme: ColorScheme) -> some View


}


SomeView()


.colorScheme(.dark)


SomeView()


.environment(.colorScheme, .dark)
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)")


func colorScheme(_ colorScheme: ColorScheme) -> some View


}


@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *)


extension View {


func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View


}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)


@available(macOS, unavailable)


extension View {


func navigationBarTitle(_ title: Text) -> some View


func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View


func navigationBarTitle<S>(_ title: S) -> some View where S : StringProtocol


func navigationBarTitle(_ title: Text, displayMode: NavigationBarItem.TitleDisplayMode) -> some View


...


}
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)


@available(macOS, unavailable)


extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")


@available(macOS, unavailable)

@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")


@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")


func navigationBarTitle(_ title: Text) -> some View


func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View


func navigationBarTitle<S>(_ title: S) -> some View where S : StringProtocol


@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with
navigationBarTitleDisplayMode(_:)")


func navigationBarTitle(_ title: Text, displayMode: NavigationBarItem.TitleDisplayMode) -> some View


...


}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)


extension View {


func navigationTitle(_ title: Text) -> some View


func navigationTitle(_ titleKey: LocalizedStringKey) -> some View


func navigationTitle<S>(_ title: S) -> some View where S : StringProtocol


}
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)


extension View {


func navigationTitle(_ title: Text) -> some View


func navigationTitle(_ titleKey: LocalizedStringKey) -> some View


func navigationTitle<S>(_ title: S) -> some View where S : StringProtocol


}


@available(iOS 14.0, *)


@available(macOS, unavailable)


@available(tvOS, unavailable)


@available(watchOS, unavailable)


extension View {


func navigationBarTitleDisplayMode(_ displayMode: NavigationBarItem.TitleDisplayMode) -> some View


}
NavigationView {


Text("Deprecated APIs Example")


.navigationTitle("Inline Mode Title")


.navigationBarTitleDisplayMode(.inline)


}


NavigationView {


Text("Deprecated APIs Example")


.navigationTitle("Large Mode Title")


.navigationBarTitleDisplayMode(.large)


}
[ inline ] [ large ]
#if os(macOS)


extension View {


func navigationBarTitle<S>(_ title: S) -> some View where S: StringProtocol {


self


}


func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View {


self


}


func navigationBarTitle(_ title: Text) -> some View {


self


}


}


#endif
extension View {


@available(iOS 13.0, tvOS 13.0, *)


@available(macOS, unavailable)


@available(watchOS, unavailable)


func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View


func navigationBarItems<L>(leading: L) -> some View where L : View


func navigationBarItems<T>(trailing: T) -> some View where T : View


}
extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading
or navigationBarTrailing placement")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading
or navigationBarTrailing placement")


@available(macOS, unavailable)

@available(watchOS, unavailable)


func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View


func navigationBarItems<L>(leading: L) -> some View where L : View


func navigationBarItems<T>(trailing: T) -> some View where T : View


}
extension View {


@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading
or navigationBarTrailing placement")


@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading
or navigationBarTrailing placement")


@available(macOS, unavailable)

@available(watchOS, unavailable)


func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View


func navigationBarItems<L>(leading: L) -> some View where L : View


func navigationBarItems<T>(trailing: T) -> some View where T : View


}


@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)


extension View {


func toolbar<Content>(@ViewBuilder content: () -> Content) -> some View where Content : View


func toolbar<Content>(@ToolbarContentBuilder content: () -> Content) -> some View where Content :
ToolbarContent


func toolbar<Content>(id: String, @ToolbarContentBuilder content: () -> Content) -> some View where
Content : CustomizableToolbarContent


}
var body: some View {

NavigationView {


Image("SwiftUI")


.navigationBarItems(leading: leadingItem, trailing: trailingItem)


.navigationBarTitle("NavigationBarItems")


}


}


var leadingItem: some View {


Button(action: { print("Leading Item") }) {


Image(systemName: "bell")


}


}


var trailingItem: some View {


HStack {


Button(action: { print("Trailing Item 1") }) {

Image(systemName: "square.and.arrow.up")


}


Button(action: { print("Trailing Item 2") }) {


Image(systemName: "gear")


}


}


}
NavigationView {


Image("SwiftUI")


.navigationTitle("Toolbar")


.toolbar {


HStack {


Button(action: { print("Toolbar Item 1") }) {


Image(systemName: "square.and.arrow.up")


}


Button(action: { print("Toolbar Item 2") }) {


Image(systemName: "gear")


}


}


}


}
.toolbar {


ToolbarItem(placement: .navigationBarLeading) {


Button(action: { print("Leading Item") }) {


Image(systemName: "bell")


}


}


ToolbarItem(placement: .navigationBarTrailing) {


HStack {


Button(action: { print("Trailing Item 1") }) {


Image(systemName: "square.and.arrow.up")


}


Button(action: { print("Trailing Item 2") }) {


Image(systemName: "gear")


}


}


}


}
NavigationView {


Text("Toolbar Action")

.font(.title)


.toolbar {


ToolbarItem(placement: .destructiveAction) {


Button("Delete", action: { presentation.wrappedValue.dismiss() })


}


ToolbarItem(placement: .confirmationAction) {


Button("Confirm", action: { presentation.wrappedValue.dismiss() })


}


ToolbarItem(placement: .cancellationAction) {


Button("Cancel", action: { presentation.wrappedValue.dismiss() })


}


}


}
[ .principal (inlineMode) ][ .principal (largeMode) ]
[ .navigation (+ backButton) ][ .navigation ]
[ .navigation (+ backButton) ][ .navigation ]
var body: some Scene {


WindowGroup {


ContentView()


}


.commands {


ToolbarCommands()


}


}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *)


extension View {


func contextMenu<MenuItems>(_ contextMenu: ContextMenu<MenuItems>?) -> some View where MenuItems : View


}


@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *)


extension View {


func contextMenu<MenuItems>(@ViewBuilder menuItems: () -> MenuItems) -> some View where MenuItems : View


}
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")


@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.")


@available(tvOS, unavailable)


@available(watchOS, introduced: 6.0, deprecated: 7.0)


extension View {


func contextMenu<MenuItems>(_ contextMenu: ContextMenu<MenuItems>?) -> some View where MenuItems : View


}


@available(iOS 13.0, macOS 10.15, tvOS 14.0, *)

@available(watchOS, introduced: 6.0, deprecated: 7.0)


extension View {


func contextMenu<MenuItems>(@ViewBuilder menuItems: () -> MenuItems) -> some View where MenuItems : View


}
var body: some View {

let contextMenu = ContextMenu {


Button(" ") { print(" ...") }


Button(" ") { print(" ...") }


Button(" ") { print(" ...") }


}


return Text(" ")


.foregroundColor(.white)


.padding(10)


.background(Color.green.cornerRadius(10))

.contextMenu(contextMenu)


}
var body: some View {

Text(" ")


.foregroundColor(.white)


.padding(10)


.background(Color.green.cornerRadius(10))


.contextMenu {


Button(" ") { print(" ...") }


Button(" ") { print(" ...") }

Button(" ") { print(" ...") }

}


}
var body: some View {

Menu(" ") {


Button(" ") { print(" ...") }


Button(" ") { print(" ...") }


Button(" ") { print(" ...") }


}


.foregroundColor(.white)


.padding(10)


.background(Color.green.cornerRadius(10))

}
extension DropInfo {

func hasItemsConforming(to types: [String]) -> Bool


func itemProviders(for types: [String]) -> [NSItemProvider]


}


extension View {


func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider]) -> Bool) -> some View

func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider], CGPoint) -> Bool) -> some View


func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View


}


extension DynamicViewContent {


func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) ->
Void) -> some DynamicViewContent


}
extension DropInfo {

func hasItemsConforming(to types: [String]) -> Bool


func itemProviders(for types: [String]) -> [NSItemProvider]


}


extension View {


func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider]) -> Bool) -> some View

func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider], CGPoint) -> Bool) -> some View


func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View


}


extension DynamicViewContent {


func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) ->
Void) -> some DynamicViewContent


}
extension DropInfo {

func hasItemsConforming(to types: [String]) -> Bool


func itemProviders(for types: [String]) -> [NSItemProvider]


}


extension View {


func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider]) -> Bool) -> some View

func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider], CGPoint) -> Bool) -> some View


func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View


}


extension DynamicViewContent {


func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) ->
Void) -> some DynamicViewContent


}
struct DropInfo {

func hasItemsConforming(to contentTypes: [UTType]) -> Bool


func itemProviders(for contentTypes: [UTType]) -> [NSItemProvider]


}


extension View {


func onDrop(of supportedContentTypes: [UTType], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider]) -> Bool) -> some View

func onDrop(of supportedContentTypes: [UTType], isTargeted: Binding<Bool>?, perform action: @escaping
([NSItemProvider], CGPoint) -> Bool) -> some View


func onDrop(of supportedContentTypes: [UTType], delegate: DropDelegate) -> some View


}


extension DynamicViewContent {


func onInsert(of supportedContentTypes: [UTType], perform action: @escaping (Int, [NSItemProvider]) -> Void)
-> some DynamicViewContent


}
struct ImageDroppableView: View {


let imageNames = ["cat1", "cat2", "dog1", "dog2"]


var body: some View {


VStack {


HStack {


ForEach(imageNames, id: .self) { imageName -> AnyView in


let imageURL = Bundle.main.url(forResource: imageName, withExtension: "jpg")!


return AnyView(


Image(nsImage: NSImage(byReferencing: imageURL))


.resizable()


.aspectRatio(3/2, contentMode: .fit)


.onDrag { NSItemProvider(object: imageURL as NSURL) }


)


}


}


DropZone()


}


}


}
struct ImageDroppableView: View {


let imageNames = ["cat1", "cat2", "dog1", "dog2"]


var body: some View {


VStack {


HStack {


ForEach(imageNames, id: .self) { imageName -> AnyView in


let imageURL = Bundle.main.url(forResource: imageName, withExtension: "jpg")!


return AnyView(


Image(nsImage: NSImage(byReferencing: imageURL))


.resizable()


.aspectRatio(3/2, contentMode: .fit)


.onDrag { NSItemProvider(object: imageURL as NSURL) }


)


}


}


DropZone()


}


}


}
struct DropZone: View {


@State private var isTargeted = false


@State private var image: NSImage? = nil


var body: some View {


Rectangle()


.fill(isTargeted ? Color.green : Color.secondary)


.overlay(Text("Drop Zone").font(.largeTitle))


.overlay(Image(nsImage: image ?? NSImage()).resizable().scaledToFit())


.onDrop(of: ["public.file-url"], isTargeted: $isTargeted, perform: { items in


guard let item = items.first else { return false }


item.loadItem(forTypeIdentifier: "public.file-url") { (data, error) in


if let urlData = data as? Data,


let url = URL(dataRepresentation: urlData, relativeTo: nil) {


image = NSImage(byReferencing: url)


}


}


return true


})


}


}
struct DropZone: View {


@State private var isTargeted = false


@State private var image: NSImage? = nil


var body: some View {


Rectangle()


.fill(isTargeted ? Color.green : Color.secondary)


.overlay(Text("Drop Zone").font(.largeTitle))


.overlay(Image(nsImage: image ?? NSImage()).resizable().scaledToFit())


.onDrop(of: ["public.file-url"], isTargeted: $isTargeted, perform: { items in


guard let item = items.first else { return false }


item.loadItem(forTypeIdentifier: "public.file-url") { (data, error) in


if let urlData = data as? Data,


let url = URL(dataRepresentation: urlData, relativeTo: nil) {


image = NSImage(byReferencing: url)


}


}


return true


})


}


}
struct DropZone: View {


@State private var isTargeted = false


@State private var image: NSImage? = nil


var body: some View {


Rectangle()


.fill(isTargeted ? Color.green : Color.secondary)


.overlay(Text("Drop Zone").font(.largeTitle))


.overlay(Image(nsImage: image ?? NSImage()).resizable().scaledToFit())


.onDrop(of: [.fileURL], isTargeted: $isTargeted, perform: { items in


guard let item = items.first else { return false }


item.loadItem(forTypeIdentifier: UTType.fileURL.identifier) { (data, error) in


if let urlData = data as? Data,


let url = URL(dataRepresentation: urlData, relativeTo: nil) {


image = NSImage(byReferencing: url)


}


}


return true


})


}


}
import UniformTypeIdentifiers
Accessibility APIs
navigationBarTitle(_:)
edgesIgnoringSafeArea(_:)
colorScheme(_:)
contextMenu(_:)
navigationBarItems(_:)
Drag & Drop UTI (String)
navigationTitle(_:)


navigationBarTitleDisplayMode(_:)
ignoresSafeArea(_:edges:)
preferredColorScheme(_:)
contextMenu(menuItems:)
toolbar(content:)
Drag & Drop UTI (UTType)
Fourenn@naver.com

More Related Content

What's hot

From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»e-Legion
 
jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0guest644d1d
 
Delivering a Responsive UI
Delivering a Responsive UIDelivering a Responsive UI
Delivering a Responsive UIRebecca Murphey
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcionalNSCoder Mexico
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureGarann Means
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHPTaras Kalapun
 
[Swift] Memento
[Swift] Memento[Swift] Memento
[Swift] MementoBill Kim
 

What's hot (13)

From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
 
jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0jQuery1.2.cheatsheet.v1.0
jQuery1.2.cheatsheet.v1.0
 
Delivering a Responsive UI
Delivering a Responsive UIDelivering a Responsive UI
Delivering a Responsive UI
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcional
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
Using Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer ArchitectureUsing Templates to Achieve Awesomer Architecture
Using Templates to Achieve Awesomer Architecture
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
 
jQuery
jQueryjQuery
jQuery
 
[Swift] Memento
[Swift] Memento[Swift] Memento
[Swift] Memento
 
jQuery
jQueryjQuery
jQuery
 

Similar to DeprecatedAPI로 알아보는 SwiftUI

Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기진성 오
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kirill Rozov
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!John De Goes
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수용 최
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutinesFabio Collini
 
미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정SeungChul Kang
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java DevelopersChris Bailey
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme SwiftMovel
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingVincent Pradeilles
 
{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}Anthony Levings
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1Troy Miles
 
Cocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftCocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftMichele Titolo
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
 

Similar to DeprecatedAPI로 알아보는 SwiftUI (20)

Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기
 
Miracle of std lib
Miracle of std libMiracle of std lib
Miracle of std lib
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!All Aboard The Scala-to-PureScript Express!
All Aboard The Scala-to-PureScript Express!
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutines
 
미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java Developers
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme Swift
 
Implementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional ProgramingImplementing pseudo-keywords through Functional Programing
Implementing pseudo-keywords through Functional Programing
 
{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}{"JSON, Swift and Type Safety" : "It's a wrap"}
{"JSON, Swift and Type Safety" : "It's a wrap"}
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 
Cocoa Design Patterns in Swift
Cocoa Design Patterns in SwiftCocoa Design Patterns in Swift
Cocoa Design Patterns in Swift
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 

More from Bongwon Lee

Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUIBongwon Lee
 
GraphQL over REST
GraphQL over RESTGraphQL over REST
GraphQL over RESTBongwon Lee
 
The Sandbox Container Directory
The Sandbox Container DirectoryThe Sandbox Container Directory
The Sandbox Container DirectoryBongwon Lee
 
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Bongwon Lee
 
LetSwift 2017 - ARKit
LetSwift 2017 - ARKitLetSwift 2017 - ARKit
LetSwift 2017 - ARKitBongwon Lee
 
Realm, Mobile Database
Realm, Mobile DatabaseRealm, Mobile Database
Realm, Mobile DatabaseBongwon Lee
 
Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Bongwon Lee
 

More from Bongwon Lee (8)

Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
App Lifecycle
App LifecycleApp Lifecycle
App Lifecycle
 
GraphQL over REST
GraphQL over RESTGraphQL over REST
GraphQL over REST
 
The Sandbox Container Directory
The Sandbox Container DirectoryThe Sandbox Container Directory
The Sandbox Container Directory
 
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
 
LetSwift 2017 - ARKit
LetSwift 2017 - ARKitLetSwift 2017 - ARKit
LetSwift 2017 - ARKit
 
Realm, Mobile Database
Realm, Mobile DatabaseRealm, Mobile Database
Realm, Mobile Database
 
Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)
 

Recently uploaded

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 

Recently uploaded (20)

A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 

DeprecatedAPI로 알아보는 SwiftUI

  • 1.
  • 2.
  • 3. Accessibility APIs navigationBarTitle(_:) edgesIgnoringSafeArea(_:) colorScheme(_:) contextMenu(_:) navigationBarItems(_:) Drag & Drop UTI (String) navigationTitle(_:) navigationBarTitleDisplayMode(_:) ignoresSafeArea(_:edges:) preferredColorScheme(_:) contextMenu(menuItems:) toolbar(content:) Drag & Drop UTI (UTType)
  • 4.
  • 5. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ... }
  • 6. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ... }
  • 7. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ... }
  • 8. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") @available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ... } @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) extension View { func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibilityLabel(_ label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibilityValue(_ value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibilityHint(_ hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ... }
  • 9.
  • 13. min(number1, number2) zip(sequence1, sequence2) UInt16(truncating: NSNumber(value: UInt32.max)) // 4294967295 -> 65535 UInt16(bigEndian: 123) // 123 -> 31488 UInt32(someUInt16number) Int64(someInt8number)
  • 14. min(number1, number2) zip(sequence1, sequence2) UInt16(truncating: NSNumber(value: UInt32.max)) // 4294967295 -> 65535 UInt16(bigEndian: 123) // 123 -> 31488 UInt32(someUInt16number) Int64(someInt8number)
  • 15. min(number1, number2) zip(sequence1, sequence2) func trimmedPath(from: CGFloat, to: CGFloat) -> Path func move(to p: CGPoint) UInt16(truncating: NSNumber(value: UInt32.max)) // 4294967295 -> 65535 UInt16(bigEndian: 123) // 123 -> 31488 UInt32(someUInt16number) Int64(someInt8number)
  • 16.
  • 17. func addSubview(_ view: UIView) func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
  • 18. func addSubview(_ view: UIView) func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle
  • 19. func addSubview(_ view: UIView) func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle func add(Subview view: UIView)
  • 20. func addSubview(_ view: UIView) func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ⛔ func add(Subview view: UIView)
  • 21. func addSubview(_ view: UIView) func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibilityLabel(_ label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibilityValue(_ value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibilityHint(_ hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ✅ func accessibility(hidden: Bool) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(label: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(value: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> func accessibility(hint: Text) -> ModifiedContent<Self, AccessibilityAttachmentModifier> ⛔ func add(Subview view: UIView)
  • 22. Slider(value: $opacity) { Text("Slider") } .accessibilityLabel("Opacity slider") .accessibilityAction(.escape) { opacity = 0.0 } .accessibilityAction(.magicTap) { opacity = 1.0 } .accessibilityAdjustableAction { direction in switch direction { case .increment: opacity += 0.05 case .decrement: opacity -= 0.05 default: break } }
  • 23. Slider(value: $opacity) { Text("Slider") } .accessibilityLabel("Opacity slider") .accessibilityAction(.escape) { opacity = 0.0 } .accessibilityAction(.magicTap) { opacity = 1.0 } .accessibilityAdjustableAction { direction in switch direction { case .increment: opacity += 0.05 case .decrement: opacity -= 0.05 default: break } }
  • 24. Slider(value: $opacity) { Text("Slider") } .accessibilityLabel("Opacity slider") .accessibilityAction(.escape) { opacity = 0.0 } .accessibilityAction(.magicTap) { opacity = 1.0 } .accessibilityAdjustableAction { direction in switch direction { case .increment: opacity += 0.05 case .decrement: opacity -= 0.05 default: break } }
  • 25. Slider(value: $opacity) { Text("Slider") } .accessibilityLabel("Opacity slider") .accessibilityAction(.escape) { opacity = 0.0 } .accessibilityAction(.magicTap) { opacity = 1.0 } .accessibilityAdjustableAction { direction in switch direction { case .increment: opacity += 0.05 case .decrement: opacity -= 0.05 default: break } }
  • 26. Image(decorative: "SwiftUI") .opacity(opacity) Text("SwiftUI Logo Image") .font(.caption) .opacity(opacity) .onTapGesture { opacity += 0.1 } .accessibilityValue("Opacity (opacity, specifier: "%.2f")") .accessibilityAddTraits(.isButton) .accessibilityScrollAction { (edge) in switch edge { case .top: opacity -= 0.5 case .bottom: opacity += 0.5 case .leading: opacity -= 0.2 case .trailing: opacity += 0.2 } }
  • 27. Image(decorative: "SwiftUI") .opacity(opacity) Text("SwiftUI Logo Image") .font(.caption) .opacity(opacity) .onTapGesture { opacity += 0.1 } .accessibilityValue("Opacity (opacity, specifier: "%.2f")") .accessibilityAddTraits(.isButton) .accessibilityScrollAction { (edge) in switch edge { case .top: opacity -= 0.5 case .bottom: opacity += 0.5 case .leading: opacity -= 0.2 case .trailing: opacity += 0.2 } }
  • 28. Image(decorative: "SwiftUI") .opacity(opacity) Text("SwiftUI Logo Image") .font(.caption) .opacity(opacity) .onTapGesture { opacity += 0.1 } .accessibilityValue("Opacity (opacity)") .accessibilityAddTraits(.isButton) .accessibilityScrollAction { (edge) in switch edge { case .top: opacity -= 0.5 case .bottom: opacity += 0.5 case .leading: opacity -= 0.2 case .trailing: opacity += 0.2 } }
  • 29. Image(decorative: "SwiftUI") .opacity(opacity) Text("SwiftUI Logo Image") .font(.caption) .opacity(opacity) .onTapGesture { opacity += 0.1 } .accessibilityValue("Opacity (opacity, specifier: "%.2f")") .accessibilityAddTraits(.isButton) .accessibilityScrollAction { (edge) in switch edge { case .top: opacity -= 0.5 case .bottom: opacity += 0.5 case .leading: opacity -= 0.2 case .trailing: opacity += 0.2 } }
  • 30. Image(decorative: "SwiftUI") .opacity(opacity) Text("SwiftUI Logo Image") .font(.caption) .opacity(opacity) .onTapGesture { opacity += 0.1 } .accessibilityValue("Opacity (opacity, specifier: "%.2f")") .accessibilityAddTraits(.isButton) .accessibilityScrollAction { (edge) in switch edge { case .top: opacity -= 0.5 case .bottom: opacity += 0.5 case .leading: opacity -= 0.2 case .trailing: opacity += 0.2 } }
  • 31.
  • 32. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View }
  • 33. @available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") @available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") @available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") @available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") extension View { func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View }
  • 34. @available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") @available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") @available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") @available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use ignoresSafeArea(_:edges:) instead.") extension View { func edgesIgnoringSafeArea(_ edges: Edge.Set) -> some View } @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) extension View { func ignoresSafeArea(_ regions: SafeAreaRegions = .all, edges: Edge.Set = .all) -> some View }
  • 35.
  • 36. [ ignore (.all) ][ 미적용 ]
  • 37. [ ignore (.all) ][ 미적용 ] [ ignore (.keyboard) ]
  • 38. [ ignore (.all) ] [ ignore (.container) ][ 미적용 ] [ ignore (.keyboard) ]
  • 39. [ .top ][ 미적용 ]
  • 40. [ .top ][ 미적용 ] [ .top, .bottom ]
  • 41. [ .top ] [ .bottom ][ 미적용 ] [ .top, .bottom ]
  • 42.
  • 43.
  • 44. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { func colorScheme(_ colorScheme: ColorScheme) -> some View }
  • 45. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") func colorScheme(_ colorScheme: ColorScheme) -> some View }
  • 46. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") func colorScheme(_ colorScheme: ColorScheme) -> some View } SomeView() .colorScheme(.dark) SomeView() .environment(.colorScheme, .dark)
  • 47. @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") @available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "preferredColorScheme(_:)") func colorScheme(_ colorScheme: ColorScheme) -> some View } @available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *) extension View { func preferredColorScheme(_ colorScheme: ColorScheme?) -> some View }
  • 48.
  • 49.
  • 50.
  • 51.
  • 52. @available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) @available(macOS, unavailable) extension View { func navigationBarTitle(_ title: Text) -> some View func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View func navigationBarTitle<S>(_ title: S) -> some View where S : StringProtocol func navigationBarTitle(_ title: Text, displayMode: NavigationBarItem.TitleDisplayMode) -> some View ... }
  • 53. @available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) @available(macOS, unavailable) extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)") @available(macOS, unavailable) @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)") @available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "navigationTitle(_:)") func navigationBarTitle(_ title: Text) -> some View func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View func navigationBarTitle<S>(_ title: S) -> some View where S : StringProtocol @available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)") func navigationBarTitle(_ title: Text, displayMode: NavigationBarItem.TitleDisplayMode) -> some View ... }
  • 54. @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) extension View { func navigationTitle(_ title: Text) -> some View func navigationTitle(_ titleKey: LocalizedStringKey) -> some View func navigationTitle<S>(_ title: S) -> some View where S : StringProtocol }
  • 55. @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) extension View { func navigationTitle(_ title: Text) -> some View func navigationTitle(_ titleKey: LocalizedStringKey) -> some View func navigationTitle<S>(_ title: S) -> some View where S : StringProtocol } @available(iOS 14.0, *) @available(macOS, unavailable) @available(tvOS, unavailable) @available(watchOS, unavailable) extension View { func navigationBarTitleDisplayMode(_ displayMode: NavigationBarItem.TitleDisplayMode) -> some View }
  • 56.
  • 57. NavigationView { Text("Deprecated APIs Example") .navigationTitle("Inline Mode Title") .navigationBarTitleDisplayMode(.inline) } NavigationView { Text("Deprecated APIs Example") .navigationTitle("Large Mode Title") .navigationBarTitleDisplayMode(.large) } [ inline ] [ large ]
  • 58. #if os(macOS) extension View { func navigationBarTitle<S>(_ title: S) -> some View where S: StringProtocol { self } func navigationBarTitle(_ titleKey: LocalizedStringKey) -> some View { self } func navigationBarTitle(_ title: Text) -> some View { self } } #endif
  • 59.
  • 60. extension View { @available(iOS 13.0, tvOS 13.0, *) @available(macOS, unavailable) @available(watchOS, unavailable) func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View func navigationBarItems<L>(leading: L) -> some View where L : View func navigationBarItems<T>(trailing: T) -> some View where T : View }
  • 61. extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement") @available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement") @available(macOS, unavailable) @available(watchOS, unavailable) func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View func navigationBarItems<L>(leading: L) -> some View where L : View func navigationBarItems<T>(trailing: T) -> some View where T : View }
  • 62. extension View { @available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement") @available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use toolbar(_:) with navigationBarLeading or navigationBarTrailing placement") @available(macOS, unavailable) @available(watchOS, unavailable) func navigationBarItems<L, T>(leading: L, trailing: T) -> some View where L : View, T : View func navigationBarItems<L>(leading: L) -> some View where L : View func navigationBarItems<T>(trailing: T) -> some View where T : View } @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) extension View { func toolbar<Content>(@ViewBuilder content: () -> Content) -> some View where Content : View func toolbar<Content>(@ToolbarContentBuilder content: () -> Content) -> some View where Content : ToolbarContent func toolbar<Content>(id: String, @ToolbarContentBuilder content: () -> Content) -> some View where Content : CustomizableToolbarContent }
  • 63. var body: some View { NavigationView { Image("SwiftUI") .navigationBarItems(leading: leadingItem, trailing: trailingItem) .navigationBarTitle("NavigationBarItems") } } var leadingItem: some View { Button(action: { print("Leading Item") }) { Image(systemName: "bell") } } var trailingItem: some View { HStack { Button(action: { print("Trailing Item 1") }) { Image(systemName: "square.and.arrow.up") } Button(action: { print("Trailing Item 2") }) { Image(systemName: "gear") } } }
  • 64. NavigationView { Image("SwiftUI") .navigationTitle("Toolbar") .toolbar { HStack { Button(action: { print("Toolbar Item 1") }) { Image(systemName: "square.and.arrow.up") } Button(action: { print("Toolbar Item 2") }) { Image(systemName: "gear") } } } }
  • 65. .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: { print("Leading Item") }) { Image(systemName: "bell") } } ToolbarItem(placement: .navigationBarTrailing) { HStack { Button(action: { print("Trailing Item 1") }) { Image(systemName: "square.and.arrow.up") } Button(action: { print("Trailing Item 2") }) { Image(systemName: "gear") } } } }
  • 66.
  • 67. NavigationView { Text("Toolbar Action") .font(.title) .toolbar { ToolbarItem(placement: .destructiveAction) { Button("Delete", action: { presentation.wrappedValue.dismiss() }) } ToolbarItem(placement: .confirmationAction) { Button("Confirm", action: { presentation.wrappedValue.dismiss() }) } ToolbarItem(placement: .cancellationAction) { Button("Cancel", action: { presentation.wrappedValue.dismiss() }) } } }
  • 68.
  • 69.
  • 70. [ .principal (inlineMode) ][ .principal (largeMode) ]
  • 71. [ .navigation (+ backButton) ][ .navigation ]
  • 72. [ .navigation (+ backButton) ][ .navigation ]
  • 73.
  • 74.
  • 75. var body: some Scene { WindowGroup { ContentView() } .commands { ToolbarCommands() } }
  • 76.
  • 77.
  • 78. @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *) extension View { func contextMenu<MenuItems>(_ contextMenu: ContextMenu<MenuItems>?) -> some View where MenuItems : View } @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *) extension View { func contextMenu<MenuItems>(@ViewBuilder menuItems: () -> MenuItems) -> some View where MenuItems : View }
  • 79. @available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.") @available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use `contextMenu(menuItems:)` instead.") @available(tvOS, unavailable) @available(watchOS, introduced: 6.0, deprecated: 7.0) extension View { func contextMenu<MenuItems>(_ contextMenu: ContextMenu<MenuItems>?) -> some View where MenuItems : View } @available(iOS 13.0, macOS 10.15, tvOS 14.0, *) @available(watchOS, introduced: 6.0, deprecated: 7.0) extension View { func contextMenu<MenuItems>(@ViewBuilder menuItems: () -> MenuItems) -> some View where MenuItems : View }
  • 80. var body: some View { let contextMenu = ContextMenu { Button(" ") { print(" ...") } Button(" ") { print(" ...") } Button(" ") { print(" ...") } } return Text(" ") .foregroundColor(.white) .padding(10) .background(Color.green.cornerRadius(10)) .contextMenu(contextMenu) }
  • 81. var body: some View { Text(" ") .foregroundColor(.white) .padding(10) .background(Color.green.cornerRadius(10)) .contextMenu { Button(" ") { print(" ...") } Button(" ") { print(" ...") } Button(" ") { print(" ...") } } }
  • 82. var body: some View { Menu(" ") { Button(" ") { print(" ...") } Button(" ") { print(" ...") } Button(" ") { print(" ...") } } .foregroundColor(.white) .padding(10) .background(Color.green.cornerRadius(10)) }
  • 83.
  • 84.
  • 85.
  • 86. extension DropInfo { func hasItemsConforming(to types: [String]) -> Bool func itemProviders(for types: [String]) -> [NSItemProvider] } extension View { func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider]) -> Bool) -> some View func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider], CGPoint) -> Bool) -> some View func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View } extension DynamicViewContent { func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent }
  • 87. extension DropInfo { func hasItemsConforming(to types: [String]) -> Bool func itemProviders(for types: [String]) -> [NSItemProvider] } extension View { func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider]) -> Bool) -> some View func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider], CGPoint) -> Bool) -> some View func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View } extension DynamicViewContent { func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent }
  • 88. extension DropInfo { func hasItemsConforming(to types: [String]) -> Bool func itemProviders(for types: [String]) -> [NSItemProvider] } extension View { func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider]) -> Bool) -> some View func onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider], CGPoint) -> Bool) -> some View func onDrop(of supportedTypes: [String], delegate: DropDelegate) -> some View } extension DynamicViewContent { func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent }
  • 89. struct DropInfo { func hasItemsConforming(to contentTypes: [UTType]) -> Bool func itemProviders(for contentTypes: [UTType]) -> [NSItemProvider] } extension View { func onDrop(of supportedContentTypes: [UTType], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider]) -> Bool) -> some View func onDrop(of supportedContentTypes: [UTType], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider], CGPoint) -> Bool) -> some View func onDrop(of supportedContentTypes: [UTType], delegate: DropDelegate) -> some View } extension DynamicViewContent { func onInsert(of supportedContentTypes: [UTType], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent }
  • 90. struct ImageDroppableView: View { let imageNames = ["cat1", "cat2", "dog1", "dog2"] var body: some View { VStack { HStack { ForEach(imageNames, id: .self) { imageName -> AnyView in let imageURL = Bundle.main.url(forResource: imageName, withExtension: "jpg")! return AnyView( Image(nsImage: NSImage(byReferencing: imageURL)) .resizable() .aspectRatio(3/2, contentMode: .fit) .onDrag { NSItemProvider(object: imageURL as NSURL) } ) } } DropZone() } } }
  • 91. struct ImageDroppableView: View { let imageNames = ["cat1", "cat2", "dog1", "dog2"] var body: some View { VStack { HStack { ForEach(imageNames, id: .self) { imageName -> AnyView in let imageURL = Bundle.main.url(forResource: imageName, withExtension: "jpg")! return AnyView( Image(nsImage: NSImage(byReferencing: imageURL)) .resizable() .aspectRatio(3/2, contentMode: .fit) .onDrag { NSItemProvider(object: imageURL as NSURL) } ) } } DropZone() } } }
  • 92. struct DropZone: View { @State private var isTargeted = false @State private var image: NSImage? = nil var body: some View { Rectangle() .fill(isTargeted ? Color.green : Color.secondary) .overlay(Text("Drop Zone").font(.largeTitle)) .overlay(Image(nsImage: image ?? NSImage()).resizable().scaledToFit()) .onDrop(of: ["public.file-url"], isTargeted: $isTargeted, perform: { items in guard let item = items.first else { return false } item.loadItem(forTypeIdentifier: "public.file-url") { (data, error) in if let urlData = data as? Data, let url = URL(dataRepresentation: urlData, relativeTo: nil) { image = NSImage(byReferencing: url) } } return true }) } }
  • 93. struct DropZone: View { @State private var isTargeted = false @State private var image: NSImage? = nil var body: some View { Rectangle() .fill(isTargeted ? Color.green : Color.secondary) .overlay(Text("Drop Zone").font(.largeTitle)) .overlay(Image(nsImage: image ?? NSImage()).resizable().scaledToFit()) .onDrop(of: ["public.file-url"], isTargeted: $isTargeted, perform: { items in guard let item = items.first else { return false } item.loadItem(forTypeIdentifier: "public.file-url") { (data, error) in if let urlData = data as? Data, let url = URL(dataRepresentation: urlData, relativeTo: nil) { image = NSImage(byReferencing: url) } } return true }) } }
  • 94. struct DropZone: View { @State private var isTargeted = false @State private var image: NSImage? = nil var body: some View { Rectangle() .fill(isTargeted ? Color.green : Color.secondary) .overlay(Text("Drop Zone").font(.largeTitle)) .overlay(Image(nsImage: image ?? NSImage()).resizable().scaledToFit()) .onDrop(of: [.fileURL], isTargeted: $isTargeted, perform: { items in guard let item = items.first else { return false } item.loadItem(forTypeIdentifier: UTType.fileURL.identifier) { (data, error) in if let urlData = data as? Data, let url = URL(dataRepresentation: urlData, relativeTo: nil) { image = NSImage(byReferencing: url) } } return true }) } } import UniformTypeIdentifiers
  • 95.
  • 96. Accessibility APIs navigationBarTitle(_:) edgesIgnoringSafeArea(_:) colorScheme(_:) contextMenu(_:) navigationBarItems(_:) Drag & Drop UTI (String) navigationTitle(_:) navigationBarTitleDisplayMode(_:) ignoresSafeArea(_:edges:) preferredColorScheme(_:) contextMenu(menuItems:) toolbar(content:) Drag & Drop UTI (UTType)