Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Artur Rymarz artrmz

🎯
Focusing
View GitHub Profile
View uiapplication_ext.swift
extension UIApplication {
func endEditing(_ force: Bool) {
self.windows
.filter{$0.isKeyWindow}
.first?
.endEditing(force)
}
}
View searchbar_swiftui.swift
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
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
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
gradient
.mask(Text("SwiftUI is awesome!").font(.largeTitle))
View gradient.swift
let gradient = LinearGradient(gradient: Gradient(colors: [.red, .orange]),
                              startPoint: .topLeading,
                              endPoint: .bottomTrailing)
View mask-example.swift
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
func mask<Mask>(_ mask: Mask) -> some View where Mask : View
View overlay-example.swift
Image("background-image")
                .resizable()
                .aspectRatio(contentMode: .fit)
                .overlay(
                    Image("top-image")
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .scaledToFit()
            )
View overlay.swift
func overlay<Overlay>(_ overlay: Overlay, alignment: Alignment = .center) -> some View where Overlay : View
You can’t perform that action at this time.