我想在我的iOS应用程序中使用-frameForAlignmentRect:和-alignmentRectForFrame:指定对齐方式.但这种方法没有调用.
我有几乎相同的iOS和Mac代码.它在OS X上完美运行,但在iOS上运行不正常.
@implementation CustomView
#define SHADOW_SIZE 10
- (void)drawRect:(NSRect)dirtyRect {
NSBezierPath *path;
[[NSColor redColor] set];
path = [NSBezierPath bezierPathWithRect:dirtyRect];
[path fill];
// Draw a shadow
NSRect rect = NSMakeRect(SHADOW_SIZE, 0, dirtyRect.size.width - SHADOW_SIZE, dirtyRect.size.height - SHADOW_SIZE);
path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:32 yRadius:32];
[[[NSColor blackColor] colorWithAlphaComponent:0.3f] set];
[path fill];
// Draw shape
rect.origin = CGPointMake(0, SHADOW_SIZE);
path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:32 yRadius:32];
[[NSColor orangeColor] set];
[path fill];
}
#define USE_ALIGNMENT_RECTS 1
#if USE_ALIGNMENT_RECTS
- (NSRect)frameForAlignmentRect:(NSRect)alignmentRect …Run Code Online (Sandbox Code Playgroud)