小编Rus*_*sik的帖子

为什么-frameForAlignmentRect:和-alignmentRectForFrame:不调用IOS

我想在我的iOS应用程序中使用-frameForAlignmentRect:-alignmentRectForFrame:指定对齐方式.但这种方法没有调用.

我有几乎相同的iOS和Mac代码.它在OS X上完美运行,但在iOS上运行不正常.

Mac版

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

uikit ios autolayout

9
推荐指数
0
解决办法
1278
查看次数

标签 统计

autolayout ×1

ios ×1

uikit ×1