Cocoa NSTextField setAlphaValue-不发生任何事情

Cocoa NSTextField setAlphaValue-不发生任何事情,cocoa,alpha,nstextfield,Cocoa,Alpha,Nstextfield,当我运行此代码时: 添加文本字段时,该字段完全没有不透明性。为什么呢 您正在将setDrawsBackground设置为否。这将自然地使文本字段透明 删除该选项将有助于获得所需的结果。您正在将setDrawsBackground设置为否。这将自然地使文本字段透明 删除它可以帮助您获得所需的结果。什么是目标SDK?它适用于我的10.7SDK。在设置alpha值之前,请尝试添加[thisPageNum SetWantLayer:YES]。目标SDK是什么?它适用于我的10.7SDK。在设置alph

当我运行此代码时:


添加文本字段时,该字段完全没有不透明性。为什么呢

您正在将setDrawsBackground设置为否。这将自然地使文本字段透明


删除该选项将有助于获得所需的结果。

您正在将setDrawsBackground设置为否。这将自然地使文本字段透明


删除它可以帮助您获得所需的结果。

什么是目标SDK?它适用于我的10.7SDK。在设置alpha值之前,请尝试添加
[thisPageNum SetWantLayer:YES]
。目标SDK是什么?它适用于我的10.7SDK。在设置alpha值之前,请尝试添加
[thisPageNum SetWantLayer:YES]
//draw the page
    thisPage = [[Page alloc] initWithFrame:NSMakeRect(25.0, 25.0, pageSize.width, pageSize.height)];
    [masterPage addSubview:thisPage];

    //get the positioning for the page number
    NSRect pageFrame = [thisPage frame];
    float xPos = pageFrame.size.width/2-pageFrame.size.width/4;
    float yPos = pageFrame.size.height/2-pageFrame.size.height/4;

    NSTextField* thisPageNum = [[NSTextField alloc] initWithFrame:NSMakeRect(xPos, yPos, 50.0, 50.0)];
    [thisPageNum setTextColor: [NSColor purpleColor]];
    [thisPageNum setAlphaValue:0.1];
    [thisPageNum setBordered: NO];
    [thisPageNum setEditable: NO];
    [thisPageNum setStringValue:[NSString stringWithFormat:@"%i", p+1]];
    [thisPageNum setFont:[NSFont fontWithName:@"Helvetica-Bold" size:36.0]];
    [thisPageNum setDrawsBackground:NO];
    [thisPage addSubview:thisPageNum];