KEMBAR78
DeprecatedAPI로 알아보는 SwiftUI | PDF
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

DeprecatedAPI로 알아보는 SwiftUI

  • 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)
  • 5.
    @available(iOS 13.0, macOS10.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, macOS10.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, macOS10.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, macOS10.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> ... }
  • 10.
  • 11.
  • 12.
  • 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) functrimmedPath(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)
  • 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 LogoImage") .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 LogoImage") .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 LogoImage") .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 LogoImage") .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 LogoImage") .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 } }
  • 32.
    @available(iOS 13.0, macOS10.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 }
  • 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 ]
  • 44.
    @available(iOS 13.0, macOS10.15, tvOS 13.0, watchOS 6.0, *) extension View { func colorScheme(_ colorScheme: ColorScheme) -> some View }
  • 45.
    @available(iOS 13.0, macOS10.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, macOS10.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, macOS10.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 }
  • 52.
    @available(iOS 13.0, tvOS13.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, tvOS13.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, macOS11.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, macOS11.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 }
  • 57.
    NavigationView { Text("Deprecated APIsExample") .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
  • 60.
    extension View { @available(iOS13.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: someView { 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") } } } }
  • 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() }) } } }
  • 70.
    [ .principal (inlineMode)][ .principal (largeMode) ]
  • 71.
    [ .navigation (+backButton) ][ .navigation ]
  • 72.
    [ .navigation (+backButton) ][ .navigation ]
  • 75.
    var body: someScene { WindowGroup { ContentView() } .commands { ToolbarCommands() } }
  • 78.
    @available(iOS 13.0, macOS10.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: someView { 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: someView { Text(" ") .foregroundColor(.white) .padding(10) .background(Color.green.cornerRadius(10)) .contextMenu { Button(" ") { print(" ...") } Button(" ") { print(" ...") } Button(" ") { print(" ...") } } }
  • 82.
    var body: someView { Menu(" ") { Button(" ") { print(" ...") } Button(" ") { print(" ...") } Button(" ") { print(" ...") } } .foregroundColor(.white) .padding(10) .background(Color.green.cornerRadius(10)) }
  • 86.
    extension DropInfo { funchasItemsConforming(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 { funchasItemsConforming(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 { funchasItemsConforming(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 { funchasItemsConforming(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
  • 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)
  • 97.