View uiapplication_ext.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIApplication { | |
func endEditing(_ force: Bool) { | |
self.windows | |
.filter{$0.isKeyWindow} | |
.first? | |
.endEditing(force) | |
} | |
} |
View searchbar_swiftui.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SearchBar: View { | |
@Binding var text: String | |
var body: some View { | |
HStack { | |
HStack { | |
Image(systemName: "magnifyingglass") | |
TextField("Search", text: $text) | |
.foregroundColor(.primary) |
View searchbar_wrapper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SearchBar: UIViewRepresentable { | |
// 1 | |
@Binding var text: String | |
// 2 | |
func makeUIView(context: Context) -> UISearchBar { | |
let searchBar = UISearchBar() | |
searchBar.delegate = context.coordinator | |
return searchBar |
View overyaly-mask-final.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let text = Text("SwiftUI is awesome!").font(.largeTitle) | |
let gradient = LinearGradient(gradient: Gradient(colors: [.red, .orange]), | |
startPoint: .topLeading, | |
endPoint: .bottomTrailing) | |
text | |
.foregroundColor(.clear) | |
.overlay( | |
gradient.mask( |
View gradient-mask.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gradient | |
.mask(Text("SwiftUI is awesome!").font(.largeTitle)) |
View gradient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gradient = LinearGradient(gradient: Gradient(colors: [.red, .orange]), | |
startPoint: .topLeading, | |
endPoint: .bottomTrailing) |
View mask-example.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Image("background-image") | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.mask( | |
ZStack { | |
Circle() | |
.frame(width: 128, height: 128) | |
Circle() | |
.frame(width: 64, height: 64) | |
.offset(x: 64, y: 32) |
View mask.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func mask<Mask>(_ mask: Mask) -> some View where Mask : View |
View overlay-example.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Image("background-image") | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.overlay( | |
Image("top-image") | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.scaledToFit() | |
) |
View overlay.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View where Overlay : View |