enum {
UIViewAnimationOptionLayoutSubviews = 1 << 0,
UIViewAnimationOptionAllowUserInteraction = 1 << 1,
UIViewAnimationOptionBeginFromCurrentState = 1 << 2,
UIViewAnimationOptionRepeat = 1 << 3,
UIViewAnimationOptionAutoreverse = 1 << 4,
UIViewAnimationOptionOverrideInheritedDuration = 1 << 5,
UIViewAnimationOptionOverrideInheritedCurve = 1 << 6,
UIViewAnimationOptionAllowAnimatedContent = 1 << 7,
UIViewAnimationOptionShowHideTransitionViews = 1 << 8,
UIViewAnimationOptionCurveEaseInOut = 0 << 16,
UIViewAnimationOptionCurveEaseIn = 1 << 16,
UIViewAnimationOptionCurveEaseOut = 2 << 16,
UIViewAnimationOptionCurveLinear = 3 << 16,
UIViewAnimationOptionTransitionNone = 0 << 20,
UIViewAnimationOptionTransitionFlipFromLeft = 1 << 20,
UIViewAnimationOptionTransitionFlipFromRight = 2 << 20,
UIViewAnimationOptionTransitionCurlUp = 3 << 20,
UIViewAnimationOptionTransitionCurlDown = 4 << 20,
};
typedef NSUInteger UIViewAnimationOptions;这个表达式的确切含义是:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse。
UIViewAnimationOptionRepeat的值等于8(在仓位10000中),UIViewAnimationOptionAutoreverse等于16(在仓位1000中)。所以我认为表达式UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse应该生成16( -> 10000) UIViewAnimationOptionReverse。
发布于 2011-07-03 01:52:37
UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse被称为“面具”。
如果你有一个UIViewAnimationOptions类型的变量,就说:
UIViewAnimationOptions a;您可以按如下方式对其应用遮罩:
bool b = a && (UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)来确定a是否“包含”这两个标志。如果
a == 0x0000001;然后
b == false;如果
a == 0x0101001; //-- completely arbitrary mask然后
b == true;因此,您实际上对UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse的计算结果不感兴趣,而只对将该类型的值与您感兴趣的检查标志进行逻辑and运算的结果感兴趣。
发布于 2011-07-03 01:53:20
操作|由真值表定义
| 0 | 1
---+---+---
0 | 0 | 1
1 | 1 | 1也就是说,仅当x == 0和y == 0都存在时才使用x | y == 0。|运算符同时处理机器字的所有位。所以
001000 (8)
| 010000 (16)
------------
011000 (24)发布于 2011-07-03 01:54:24
这些位是或的:
UIViewAnimationOptionRepeat = 1 << 3 = 8 = 01000 in binary
UIViewAnimationOptionAutoreverse = 1 << 4 = 16 = 10000 in binary
01000
OR 10000
--------
11000二进制中的11000是16 +8= 24 -设置了第三和第四位的整数(从0开始计数)。
https://stackoverflow.com/questions/6558600
复制相似问题