search

Home  >  Q&A  >  body text

objective-c - 如何比较UIView的transform属性

想判断现在旋转是否是M_PI_2,应该如何比较?

赋值的时候可以
toolView.transform = CGAffineTransformMakeRotation(-M_PI_2);

但是如果这样判断就会报错。

阿神阿神2769 days ago441

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-21 10:59:28

    The transform type of UIView is CGAffineTransform, which is a struct.
    C language does not allow direct operations on struct. You have to compare the attributes in the struct.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-21 10:59:28

    CG_EXTERN bool CGAffineTransformEqualToTransform(CGAffineTransform t1,
    CGAffineTransform t2) CG_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0);
    用这个比较

    reply
    0
  • 迷茫

    迷茫2017-04-21 10:59:28

    If you buy me some fruit tomorrow, I will tell you how to calculate the rotation angle and scaling of the affine matrix

    reply
    0
  • Cancelreply