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