swift4
- 通常のボタンタップとロングプレスを判定する
import UIKit
class ViewController: UIViewController {
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 |
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 |
extension UIImage { | |
func fixedOrientation() -> UIImage { | |
if imageOrientation == UIImageOrientation.Up { | |
return self | |
} | |
var transform: CGAffineTransform = CGAffineTransformIdentity | |
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) | |
{ |
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.
Reset PS3 controller by inserting paperclip into pinhole near L2 button.
Connect PS3 controller to Mac with USB cable.
Enable Bluetooth.