mNo edit summary |
(Added all windows method.) |
||
Line 22: | Line 22: | ||
</source> | </source> | ||
The global point is always in portrait coordinate. | The global point is always in portrait coordinate. | ||
== Getting an array of all windows == | |||
You can use the following class method to get an array of all windows. | |||
{{function signature | |||
|signature=+ (NSArray *)allWindowsIncludingInternalWindows:(BOOL)internal onlyVisibleWindows:(BOOL)visible; | |||
|firmware=4.0 – | |||
}} | |||
<source lang=objc> | |||
NSArray *windows = [UIWindow allWindowsIncludingInternalWindows:YES onlyVisibleWindows:NO]; | |||
</source> | |||
== References == | == References == | ||
* Official reference: {{sdklink|UIKit|UIWindow}}. | * Official reference: {{sdklink|UIKit|UIWindow}}. | ||
{{IPFHeader|UIKit|3=2}} | {{IPFHeader|UIKit|3=2}} |
Latest revision as of 00:54, 7 September 2013
UIWindow is a specialized UIView that represents a root node in the view hierarchy. There may be multiple UIWindows.
Non-rectangular windows
Signature | -(BOOL)acceptsGlobalPoint:(CGPoint)point; |
---|---|
Available in | 2.0 – 3.1 |
By default UIWindows are rectangular. While you may modify the interaction shape of a UIView by overriding -pointInside:withEvent:, this method will be ignored in UIWindow. Instead, there is an undocumented method -acceptsGlobalPoint: that does this job:
@interface MyWindow : UIWindow { ... }
-(BOOL)acceptsGlobalPoint:(CGPoint)pt;
@end
@implementation MyWindow
// Makes the window interacts like a circle.
-(BOOL)acceptsGlobalPoint:(CGPoint)pt {
CGFloat dx = pt.x - 160, dy = pt.y - 240;
return (dx*dx+dy*dy <= 100*100);
}
@end
The global point is always in portrait coordinate.
Getting an array of all windows
You can use the following class method to get an array of all windows.
Signature | + (NSArray *)allWindowsIncludingInternalWindows:(BOOL)internal onlyVisibleWindows:(BOOL)visible; |
---|---|
Available in | 4.0 – |
NSArray *windows = [UIWindow allWindowsIncludingInternalWindows:YES onlyVisibleWindows:NO];
References
- Official reference: UIWindow.
- Header: http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIWindow2.h