Skip to content

Instantly share code, notes, and snippets.

View calosth's full-sized avatar
🏠
Working from home

Carlos Linares calosth

🏠
Working from home
View GitHub Profile
@calosth
calosth / UIView+Intersection.swift
Last active September 8, 2022 22:59
Extension of UIView to detect collisions between them, including rotated(transformed) views.
import UIKit
// Conform the `Polygon` protocol to specify the vertices of the polygon.
protocol Polygon {
var vertices: [CGPoint] { get }
}
// UIView conforms the protocol `Polygon` to specified the vertices of the rectangle.
extension UIView: Polygon {
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
let index = CGFloat(integerLiteral: tabBar.items!.index(of: item)!)
let itemWidth = indicatorImage?.frame.width
let newCenterX = (itemWidth! / 2) + (itemWidth! * index)
UIView.animate(withDuration: 0.3) {
self.indicatorImage?.center.x = newCenterX
}
}
```json
{
"body": {
"client": {
"name": "keybase.io node.js client",
"version": "0.7.7"
},
"key": {
"fingerprint": "8c19240afd7230efb629f33d6c28a9663b79991a",
"host": "keybase.io",
@calosth
calosth / DHube.markdown
Created October 19, 2014 03:10
A Pen by Carlos Linares.
@calosth
calosth / index.html
Created August 7, 2013 19:56
via:geojson.io
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.marker-properties {
border-collapse:collapse;