Skip to content

Instantly share code, notes, and snippets.

View SuperWomble's full-sized avatar

David SuperWomble

  • Adelaide, South Australia
View GitHub Profile
@calt
calt / Tabbar.Swift
Last active January 9, 2024 05:58
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
}
}
@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)
@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{
@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]
@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()
import CoreGraphics
private typealias CGPathDumpUtility = CGPath
extension CGPathDumpUtility {
func dump() {
self.apply(info: nil) { info, unsafeElement in
let element = unsafeElement.pointee
switch element.type {
@cotkjaer
cotkjaer / CGRect+Center.swift
Last active November 23, 2023 06:15
Swift extensions to add "center" to CGRect
extension CGRect
{
/** Creates a rectangle with the given center and dimensions
- parameter center: The center of the new rectangle
- parameter size: The dimensions of the new rectangle
*/
init(center: CGPoint, size: CGSize)
{
self.init(x: center.x - size.width / 2, y: center.y - size.height / 2, width: size.width, height: size.height)
@miguelfermin
miguelfermin / PageViewController.swift
Created May 8, 2017 10:05
Demonstrates how to add a UIPageViewController to a UIViewController
//
// ViewController.swift
// PageViewController
//
// Created by Miguel Fermin on 5/8/17.
// Copyright © 2017 MAF Software LLC. All rights reserved.
//
import UIKit
@maxchuquimia
maxchuquimia / runscript.sh
Created April 28, 2018 07:51
Demo of using Swift in a Run Script phase in Xcode
#!/bin/bash
CONFIG_PASSWORD="BE5D2905-0625-4EBF-BCA2-7F6F5D138425"
REQUIRED_CONFIG_FILE_PATH="${SRCROOT}/YourProject/App/Config/Configurations/Config-${CONFIGURATION}.plist"
CONFIG_OUTPUT_PATH="${SRCROOT}/YourProject/App/Config/Configurations/Config.json"
CONFIG_EXTENSION_OUTPUT_PATH="${SRCROOT}/YourProject/App/Config/Configurations/Config+Extension.swift"
set -e
if [ -z "${CONFIGURATION}" ]
@shaps80
shaps80 / 1. UserDefaults+Key.swift
Last active September 25, 2020 08:29
Adds a Swift extension to make UserDefaults more consistent to work with.
//
// UserDefaults.swift
//
// Created by Shaps Benkau on 24/05/2018.
// Copyright © 2018 152percent Ltd. All rights reserved.
//
import Foundation
#if os(iOS)