1、唱片旋轉效果(360°無限順時針旋轉)app
func animationRotateCover() { coverImageView.layer.removeAllAnimations() let animation = CABasicAnimation(keyPath: "transform.rotation") animation.fromValue = 0 animation.toValue = CGFloat.pi * 2 animation.duration = 5 animation.isCumulative = true animation.repeatCount = Float.infinity coverImageView.layer.add(animation, forKey: nil) }
2、防止文件被 iCloud 同步備份ide
NSURLIsExcludedFromBackupKey動畫
3、禁止 UICollectionView reload/insert 動畫spa
UIView.performWithoutAnimation {
self.videoPartCollectionView.reloadData()
}
4、Objective-C 中的 performSelector 在 Swift 裏變成了 sendActioncode
var rightTappedSelector: Selector? @IBAction func rightTappedAction(_ sender: Any) { guard let selector = rightTappedSelector else { return } rightButton.sendAction(selector, to: nil, for: nil) }
5、得到 CGAffineTransform 的 rotation 信息orm
extension CGAffineTransform { func getTransformRotation() -> CGFloat { return atan2(self.b, self.a) * 180 / CGFloat.pi } }
6、獲取 Date 的 nano 時間blog
extension Date { func nanosecond() -> Int64 { let nanosecond: Int64 = Int64(Calendar.current.dateComponents([.nanosecond], from: self).nanosecond ?? 0) return Int64(self.timeIntervalSince1970 * 1000000000) + nanosecond } }
7、AVCapturePhotoOutput.capturePhoto 崩潰的問題rem
不要讓 UIViewController 實現 AVCapturePhotoCaptureDelegate ,要跟 AVCam 例子同樣弄一個 class PhotoCaptureDelegate: NSObject, AVCapturePhotoCaptureDelegate 就不崩潰了,什麼鬼問題get