1
当我运行这段代码:的NSTextField setAlphaValue - 什么也没有发生
...
//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];
当文本字段添加不存在的不透明度为它在所有。这是为什么?
什么是目标SDK?它适用于我的10.7 SDK。在设置alpha值之前,尝试添加'[thisPageNum setWantsLayer:YES]'。 – hamstergene 2012-03-05 17:35:36