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 DynamicAttributedTextView: UIViewRepresentable { | |
// MARK: - Constants | |
private static let attributes: [NSAttributedString.Key : Any] = [.font: CustomFont().UIKitFont()!, | |
.foregroundColor: UIColor.appPrimaryText, | |
.paragraphStyle: DynamicAttributedTextView.paragraphStyle] | |
private static let types: NSTextCheckingResult.CheckingType = [.link, .address, .phoneNumber] | |
private static let paragraphStyle: NSParagraphStyle = { | |
let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle() |
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 ExampleView: View { | |
// MARK: - Properties | |
@State private var size: CGSize = .zero | |
// MARK: - Updates | |
func body(content: Content) -> some View { | |
Text("Size of this label: \(Int(self.size.width)),\(Int(self.size.height))") | |
.modifier(SizeModifier({self.size = $0})) | |
} |
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
import SwiftUI | |
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable { | |
// MARK: - Coordinator | |
final class Coordinator: NSObject, UIScrollViewDelegate { | |
// MARK: - Properties | |
private let scrollView: UIScrollView | |
var offset: Binding<CGPoint> |
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
/** Returns a centered position CGRect for a given CGRect inside of a larger CGRect */ | |
CGRect centeredRect(CGRect outerRect, CGRect innerRect) { | |
CGRect centeredRect = innerRect; | |
centeredRect.origin.x = CGRectGetMidX(outerRect) - (CGRectGetWidth(innerRect) * 0.5f); | |
centeredRect.origin.y = CGRectGetMidY(outerRect) - (CGRectGetHeight(innerRect) * 0.5f); | |
return centeredRect; | |
} |