This file contains hidden or 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
class TestButton: UIButton { | |
init() { | |
super.init(frame: CGRect.zero) | |
self.layer.masksToBounds = true | |
self.layer.borderColor = UIColor.black.cgColor | |
self.layer.borderWidth = 1 / UIScreen.main.scale | |
self.layer.cornerCurve = .continuous |
This file contains hidden or 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 ScrollOffsetPreferenceKey: PreferenceKey { | |
static var defaultValue: CGPoint = .zero | |
static func reduce(value: inout CGPoint, nextValue: () -> CGPoint) {} | |
} | |
struct ScrollOffsetTestView: View { | |
var body: some View { | |
GeometryReader { proxy in | |
List { | |
SwiftUI.Section( |
This file contains hidden or 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 View { | |
/// Useful for applying modifiers that are limited to certain iOS versions | |
func modify<Content>(@ViewBuilder _ transform: (Self) -> Content) -> Content { | |
transform(self) | |
} | |
} |
This file contains hidden or 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 Test: View { | |
private let coordinateSpaceName = "StickyHeaderCoordinateSpaceName" | |
@State var counter: Int = 0 | |
@State var forEachId: UUID = UUID() | |
var body: some View { | |
ScrollView { | |
LazyVStack { | |
GeometryReader { proxy in | |
Color.red |
This file contains hidden or 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
import SwiftUI | |
struct SizePreferenceKey: PreferenceKey { | |
static var defaultValue: CGSize = .zero | |
static func reduce(value: inout CGSize, nextValue: () -> CGSize) {} | |
} | |
public extension View { | |
func readSize(onChange: @escaping (CGSize) -> Void) -> some View { | |
self |
This file contains hidden or 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 ContentView: View { | |
let data = (1...10000).map { "Item \($0)" } | |
let columns = [ | |
GridItem(.flexible()), | |
GridItem(.flexible()), | |
GridItem(.flexible()) | |
] | |
var body: some View { |