Skip to content

Instantly share code, notes, and snippets.

View AD-Paladins's full-sized avatar
🔍
🍎📲

Andres D. Paladines AD-Paladins

🔍
🍎📲
View GitHub Profile

UIButton + UILongPressGestureRecognizer

swift4

  • 通常のボタンタップとロングプレスを判定する
import UIKit

class ViewController: UIViewController {
@nor0x
nor0x / shadow+cornerradius.swift
Created December 22, 2016 17:23
UICollectionViewCell -> Corner Radius AND Shadow
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
cell.contentView.layer.cornerRadius = 2.0
cell.contentView.layer.borderWidth = 1.0
cell.contentView.layer.borderColor = UIColor.clear.cgColor
cell.contentView.layer.masksToBounds = true;
cell.layer.shadowColor = UIColor.lightGray.cgColor
cell.layer.shadowOffset = CGSize(width:0,height: 2.0)
cell.layer.shadowRadius = 2.0
cell.layer.shadowOpacity = 1.0
@mourad-brahim
mourad-brahim / UIView+Animations.swift
Last active December 1, 2022 07:29
Shake animation with swift
extension UIView {
func shake(duration: CFTimeInterval) {
let translation = CAKeyframeAnimation(keyPath: "transform.translation.x");
translation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
translation.values = [-5, 5, -5, 5, -3, 3, -2, 2, 0]
let rotation = CAKeyframeAnimation(keyPath: "transform.rotation.z")
rotation.values = [-5, 5, -5, 5, -3, 3, -2, 2, 0].map {
(let degrees: Double) -> Double in
let radians: Double = (M_PI * degrees) / 180.0
@schickling
schickling / UIImageFixedOrientationExtension.swift
Last active February 4, 2024 15:00
Extension to fix orientation of an UIImage (Sets orientation to portrait)
extension UIImage {
func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.Up {
return self
}
var transform: CGAffineTransform = CGAffineTransformIdentity
@McKay1717
McKay1717 / Uniqid
Created August 18, 2014 21:23
PHP uniqid in JAVA
public class Uniqid {
/***
* Copy of uniqid in php http://php.net/manual/fr/function.uniqid.php
* @param prefix
* @param more_entropy
* @return
*/
public String uniqid(String prefix,boolean more_entropy)
{
@statico
statico / gist:3172711
Created July 24, 2012 21:15
How to use a PS3 controller on Mac OS X 10.7 (Lion)

How to use a PS3 controller on Mac OS X 10.7 (Lion)

  1. Open Apple menu -> System Preferences -> Bluetooth and disable Bluetooth on Mac as well as any other nearby Macs or devices which will try to pair with and confuse the controller.

  2. Reset PS3 controller by inserting paperclip into pinhole near L2 button.

  3. Connect PS3 controller to Mac with USB cable.

  4. Enable Bluetooth.