From iPhone Development Wiki
Revision as of 20:11, 3 March 2010 by KennyTM~ (talk | contribs)
Jump to: navigation, search

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 { ... }

@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);

The global point is always in portrait coordinate.