Skip to content

Instantly share code, notes, and snippets.

View dsxsxsxs's full-sized avatar

dsxs dsxsxsxs

View GitHub Profile
@dsxsxsxs
dsxsxsxs / ninePatchDemo.swift
Created October 8, 2020 02:08 — forked from brandhill/ninePatchDemo.swift
Equivalent Android 9-patch for iOS and Swift 3.0 (multiple stretchable areas)
// origin
UIImageView *unHandleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 100, 200, 30)];
unHandleImg.image = [UIImage imageNamed:@"theImage"];
[self.view addSubview:unHandleImg];
// with stretchable
UIImageView *handleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 200, 200, 30)];
UIImage *img = [UIImage imageNamed:@"theImage"];
// stretchable areas
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(35, 35, 35, 35) resizingMode:UIImageResizingModeStretch];
@dsxsxsxs
dsxsxsxs / easing.js
Created November 2, 2017 06:03 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity