Swift에서 CATransform3D를 사용하는 경우
6265 단어 CATransform3DSwift
회색으로 살짝 두드리면 회색으로 된 부분이 왔다 갔다 합니다.그거밖에 없어요.
ViewController.swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let view : UIView = UIView(frame: CGRectMake(100, 100, 100, 100))
view.backgroundColor = UIColor.grayColor()
view.userInteractionEnabled = true
view.tag = 1
self.view.addSubview(view)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
let touche : UITouch = touches.anyObject() as UITouch
switch (touche.view.tag as Int) {
case 1:
let animation : CABasicAnimation = CABasicAnimation(keyPath: "transform")
animation.duration = 0.5
animation.repeatCount = 1
animation.autoreverses = true
let transform : CATransform3D = CATransform3DMakeRotation(CGFloat(M_PI), 1.0, 0.5, 0.0)
animation.toValue = NSValue(CATransform3D : transform)
touche.view.layer.addAnimation(animation, forKey: "transform")
default:
break
}
}
}
Reference
이 문제에 관하여(Swift에서 CATransform3D를 사용하는 경우), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/rnsm504/items/9314b3d1bd2413931da7텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)