2009-12-12 3 views
0

검은 색 배경의 CALayer를 표시하려고합니다. AppDelegate를 위임자로 파일 소유자에게 첨부했습니다. 콘솔은 "awaking from nib ..."로그 문을 올바르게보고합니다. 그러나 나는 중간에 그려진 블랙 박스가없는 빈 회색 창 (크기는 335x390)을 보았습니다. 내가 누락 된 개념은 무엇입니까? 도움에 미리윈도우 내부에 표시 할 CALayer를 갖고 싶습니다.

감사합니다,

찰스

#import "AppDelegate.h" 
#import <QuartzCore/QuartzCore.h> 
@implementation AppDelegate 

-(void)awakeFromNib; 
{ 
    NSLog(@"awaking from nib..."); 
    [[window contentView] setWantsLayer:YES]; 

    layer = [CALayer layer]; 
    [layer setBounds:CGRectMake(0.0,0.0,100.0,100.0)]; 

    // center the animation layer 
    [layer setPosition:CGPointMake([[window contentView] frame].size.width/2, [[window contentView]frame].size.height/2)]; 
    CGColorRef color = CGColorCreateGenericRGB(0., 0., 0., 1); 
    [layer setBackgroundColor:color]; 
    CFRelease(color); 

    [layer setBorderWidth:5.0f]; 

    [[[window contentView] layer] addSublayer:layer];  
} 
@end 

답변

0

사용자 정의 층의 건축 코드는 비록의 RGBA (1,1,1,1)와 색상 것, 올바른 보인다 검은 색이 아닌 흰색이되어야합니다.

window 속성의 콘센트가 제대로 연결되어 있는지 (nil이 아닌지 확인하십시오.) contentView가 0이 아닌지 확인하고 싶습니다. 사람들은 좋은 찾고 있다면, 당신은 다음과 같은 일을 수행하여있는 contentView에 대한 사용자 정의 계층을 제공하기 위해 시도 할 수 :

[[window contentView] setLayer:[CALayer layer]]; 
[[window contentView] setWantsLayer:YES]; 
+0

브래드, 색상 문제에 저를 정정 감사합니다. 나는 질문에서 수정하여 나중에 다른 사람들에게 혼란스럽지 않게 할 것이다. 예, "창"속성은없는 개념이 아닙니다. 감사! – Charles

관련 문제