This is a curated list of reference material that anyone who develops in the Apple domain will hopefully find helpful. Most items are things I have used and can vouch for.
--
--
import Foundation | |
extension String { | |
var containsEmoji: Bool { | |
for scalar in unicodeScalars { | |
switch scalar.value { | |
case 0x1F600...0x1F64F, // Emoticons | |
0x1F300...0x1F5FF, // Misc Symbols and Pictographs | |
0x1F680...0x1F6FF, // Transport and Map | |
0x1F900...0x1F9FF, //idk but here lies clown and others |
/* | |
Example of how to create a view that has rounded corners and a shadow. | |
These cannot be on the same layer because setting the corner radius requires masksToBounds = true. | |
When it's true, the shadow is clipped. | |
It's possible to add sublayers and set their path with a UIBezierPath(roundedRect...), but this becomes difficult when using AutoLayout. | |
Instead, we a containerView for the cornerRadius and the current view for the shadow. | |
All subviews should just be added and constrained to the containerView | |
*/ | |
import UIKit |
private var shadowLayer: CAShapeLayer! | |
private var cornerRadius: CGFloat = 25.0 | |
private var fillColor: UIColor = .blue // the color applied to the shadowLayer, rather than the view's backgroundColor | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
if shadowLayer == nil { | |
shadowLayer = CAShapeLayer() | |
This is a curated list of reference material that anyone who develops in the Apple domain will hopefully find helpful. Most items are things I have used and can vouch for.
--
--
func heightOfString(_ string: String, attributes: [NSAttributedString.Key: Any], fitting width: CGFloat) -> CGFloat { | |
let constraintRect = CGSize(width: width, height: CGFloat.greatestFiniteMagnitude) | |
let boundingRect = string.boundingRect(with: constraintRect, | |
options: [.usesLineFragmentOrigin, .usesFontLeading], | |
attributes: attributes, | |
context: nil) | |
return boundingRect.size.height | |
} |
protocol FooProtocol {} | |
protocol BarProtocol {} | |
protocol DootProtocol {} | |
typealias CompProtocol = FooProtocol & BarProtocol & DootProtocol | |
struct Dependencies: CompProtocol {} | |
struct SomeType { |
// | |
// BottomSheetView.swift | |
// field | |
// | |
// Created by Corey Walo on 12/21/22. | |
// | |
import SwiftUI | |
fileprivate enum Constants { |
import SwiftUI | |
struct IndentScrollView: View { | |
let min = 0.5 | |
let max = 3.5 | |
let increment = 0.1 | |
@State | |
var multiplier = 0.5 |
import Foundation | |
import SwiftUI | |
struct ScrollViewTracking: Equatable { | |
/// A stable identifier to name the view's coordinate space | |
let namespace: AnyHashable = UUID() | |
/// The current position of the scroll view | |
var position: CGPoint = .zero | |
/// The scroll view's content size | |
var contentSize: CGSize = .zero |