Graphics Programs Reference
In-Depth Information
bit is set to 1 if either of the original numbers had a 1 in the same position. When you
bitwise-OR a number with 2 n , it flips on the switch at the n th position. For example, if
you bitwise-OR 1 and 16, you get the following:
00000001 ( 1 10 , UIViewAutoresizingFlexibleLeftMargin)
| 00010000 (16 10 , UIViewAutoresizingFlexibleHeight)
----------
00010001 (17 10 , both UIViewAutoresizingFlexibleHeight
and UIViewAutoresizingFlexibleLeftMargin)
The complement to the bitwise-OR operator is the bitwise-AND (&) operator. When you
bitwise-AND two numbers, the result is a number that has a 1 in each bit where there is a
1 in the same position as both of the original numbers.
00010001 (17 10 , FlexibleHeight and FlexibleLeftMargin)
& 00010000 (16 10 , FlexibleHeight)
----------
00010000 (16 10 , YES)
00010001 (17 10 , FlexibleHeight and FlexibleLeftMargin)
& 00000010 ( 2 10 , FlexibleWidth)
----------
00000000 ( 0 10 , NO)
Since any non-zero number means YES (and zero is NO ), we use the bitwise-AND operat-
or to check whether a switch is on or not. Thus, when a view's autoresizing mask is
checked, the code looks like this:
if ([self autoresizingMask] & UIViewAutoresizingFlexibleHeight)
{
// Resize the height
}
Search WWH ::




Custom Search