Skip to content

Instantly share code, notes, and snippets.

View SuperWomble's full-sized avatar
💭
I may be slow to respond.

David SuperWomble

💭
I may be slow to respond.
  • Adelaide, South Australia
View GitHub Profile
import CoreGraphics
private typealias CGPathDumpUtility = CGPath
extension CGPathDumpUtility {
func dump() {
self.apply(info: nil) { info, unsafeElement in
let element = unsafeElement.pointee
switch element.type {
@timgcarlson
timgcarlson / ShapeCutout.swift
Last active June 10, 2021 22:04
Using the non-zero winding rule to cutout the path of a shape (uses bezierPathByReversingPath)
UIGraphicsBeginImageContextWithOptions(CGSize(width: 200, height: 200), false, 0.0)
let context = UIGraphicsGetCurrentContext()
let rectPath = UIBezierPath(roundedRect: CGRectMake(0, 0, 200, 200), cornerRadius: 10)
var cutoutPath = UIBezierPath(roundedRect: CGRectMake(30, 30, 140, 140), cornerRadius: 10)
rectPath.appendPath(cutoutPath.bezierPathByReversingPath())
UIColor.orangeColor().set()
outerForegroundPath.fill()
@odrobnik
odrobnik / gist:2751fb3ce32792b8a85d
Last active February 21, 2023 12:06
Swift: create CGPath from attributed string
func appendToPath(path: CGMutablePath)
{
let textPath = CGPathCreateMutable()
let attributedString = NSAttributedString(string: string)
let line = CTLineCreateWithAttributedString(attributedString)
// direct cast to typed array fails for some reason
let runs = (CTLineGetGlyphRuns(line) as [AnyObject]) as! [CTRun]
@eonist
eonist / QuartzInnerShadow.swift
Created December 10, 2015 16:55
Quartz Inner Shadow (playground)
import Cocoa
import XCPlayground
import XCTest
/*
shadow.shadowColor = NSColor.blackColor().colorWithAlphaComponent(1.0)
shadow.shadowOffset = NSMakeSize(0.1, 0.1)
shadow.shadowBlurRadius = 15
*/
extension NSShadow{
@krishaamer
krishaamer / Shadows
Created July 4, 2015 09:12
Shadow Effects for UITableView Cells
// GuestCellView.swift
import UIKit
import DynamicColor
class GuestCellView:UIView {
override func awakeFromNib() {
//applyCustomShadow(self)
@calt
calt / Tabbar.Swift
Last active April 22, 2025 05:34
UITabBar with custom height in Swift, does not work for iOS 14 or later.
// Does not work on iOS 14.0 or later, keeping the gist just for reference.
extension UITabBar {
override open func sizeThatFits(size: CGSize) -> CGSize {
super.sizeThatFits(size)
var sizeThatFits = super.sizeThatFits(size)
sizeThatFits.height = 71
return sizeThatFits
}
}