Skip to content

Instantly share code, notes, and snippets.

@z5ottu
z5ottu / uibutton.3d.transform.swift
Created January 4, 2016 11:40
Swift: UIView 3d transform animation style: horizontal flip
let layer = sender.layer
var rotationAndPerspectiveTransform : CATransform3D = CATransform3DIdentity
rotationAndPerspectiveTransform.m34 = 1.0 / -1000
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, CGFloat(M_PI / 0.3), 0.0, 1.0, 0.0)
layer.transform = rotationAndPerspectiveTransform
UIView.animateWithDuration(2.0, animations: {
layer.transform = CATransform3DIdentity
})