Skip to content

Instantly share code, notes, and snippets.

@fxm90
fxm90 / WebViewExampleViewController.swift
Last active October 24, 2024 17:52
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit
import Foundation
import UIKit
// Usage Examples
let shadowColor = Color.shadow.value
let shadowColorWithAlpha = Color.shadow.withAlpha(0.5)
let customColorWithAlpha = Color.custom(hexString: "#123edd", alpha: 0.25).value
enum Color {
@markcerqueira
markcerqueira / brew.sh
Last active December 19, 2019 03:10
Bootstrapping Mac Apps with Homebrew Cask
#!/bin/sh
# chmod a+x brew.sh
# https://computers.tutsplus.com/tutorials/perfect-configurations-with-homebrew-and-cask--cms-20768
# brew packages
brew install git
brew install gradle
brew install openssl
brew install ruby
@RF-Nelson
RF-Nelson / Tutorial.md
Last active August 18, 2024 00:02
Using the Multipeer Connectivity Framework to Create the Open Source Selfie Stick iOS App

Using the iOS Multipeer Connectivity Framework to Create Open Source Selfie Stick

In this gist, I will discuss how I used the Multipeer Connectivity framework to create Open Source Selfie Stick. Open Source Selfie Stick is a free open-source iOS app that allows users to sync two devices over WiFi or Bluetooth and allows one to act as a remote control for the other's camera.

This tutorial assumes some knowledge of the Swift programming language and iOS development with Xcode.

Feel free to comment and point out any errors or improvements. If you'd like to help improve the app itself, make a fork from dev branch of the git repo. I plan on updating this document and explaining any newly added features or refactoring. As this gist w

@koenbok
koenbok / programming.md
Created February 3, 2016 12:27
Programming Basics

Programming

Programming is hard because

  • Mix between English, logic and math.
  • It is very strict: tabs, spaces, commas and capitalization matters.
  • Errors can be hard to understand but often mean something simple.

Before we begin

extension UIView {
func forEachSubviewOfType<V: UIView>(type: V.Type, @noescape apply block: V -> Void) {
for view in subviews {
if let view = view as? V {
block(view)
} else {
view.forEachSubviewOfType(V.self, apply: block)
}
}
}
@gonzalezreal
gonzalezreal / ios-cell-registration-swift.md
Last active March 13, 2024 15:18
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
@andyyhope
andyyhope / SwiftEvolution_EnumCaseCountFunctionality_AndyyHope.md
Last active March 12, 2020 13:05
Swift Evolution - Enum Case Count Functionality

Swift Evolution Proposal

Author: Andyy Hope

Enum Values() Functionality (Update)

It has been brought to my attention that there was more use for the unintended values() functionality that I had outline in my "Other Languages" Java example below.

On the Swift Evolution mailing list, one developer outlined their requirement to loop through an array of enum case values to add different states to objects.

Another example where a values array would be useful if the developer wants to do something different for each different case, such as setting an image on a UIButton subclass for each different UIControlState

@calt
calt / Tabbar.Swift
Last active October 10, 2024 07:06
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
}
}
@iandundas
iandundas / UIImagePickerController+cats.m
Created March 16, 2015 16:19
How to detect iOS Photo library or Camera permissions (>iOS8)
//
// Created by Ian Dundas on 16/03/15.
//
#import "UIImagePickerController+cats.h"
#import <AVFoundation/AVFoundation.h>
#import "Photos/Photos.h"
/*
example usage: