如何比较CGAffinetransform?

我将如何完成这个代码,我有错误。

-(IBAction)dropDownBtn:(id)sender { dropDownBtn.transform = CGAffineTransformMakeRotation(720*M_PI/360); if ([dropDownBtn.transform CGAffineTransformMakeRotation(720*M_PI/360)) { dropDownBtn.transform = CGAffineTransformMakeRotation(520*M_PI/360); } } 

有一个函数来比较转换:

 CGAffineTransformEqualToTransform(transform1, transform2) 

在Swift中你使用等于运算符(==)

 transform1 == transform2 

如果你需要给定精度的平等testing(在unit testing中有用),我使用这个函数:

 BOOL CGAffineTransformEqualToTransformWithAccuracy (CGAffineTransform firstTransform, CGAffineTransform secondTransform, CGFloat epsilon) { return (fabs(firstTransform.a - secondTransform.a) <= epsilon) && (fabs(firstTransform.b - secondTransform.b) <= epsilon) && (fabs(firstTransform.c - secondTransform.c) <= epsilon) && (fabs(firstTransform.d - secondTransform.d) <= epsilon) && (fabs(firstTransform.tx - secondTransform.tx) <= epsilon) && (fabs(firstTransform.ty - secondTransform.ty) <= epsilon); } 

这是一个扩展:

 import CoreGraphics extension CGAffineTransform: Equatable {} public func ==(lhs: CGAffineTransform, rhs: CGAffineTransform) -> Bool { return CGAffineTransformEqualToTransform(lhs, rhs) }