2012-11-22 5 views
3

상위 뷰의 CALayer 위에 하위 뷰를 추가하는 데 문제가 있습니다. 메인 뷰 레이어 위에 서브 뷰 추가

나는 내가 무엇을 의미하는지 보여주기 위해 이미지를 첨부하려고하지만 난 그래서 여기에 이미지에 대한 링크입니다 충분한 명성을 가지고 있겠지 : 하위 뷰의

http://imageshack.us/photo/my-images/843/img0219u.png/

부분이 부모에 의해 가려

국경을 전망은 .

하위 뷰를 상위 뷰 레이어의 맨 위에 표시하려면 어떻게해야합니까?

도움을 주시면 감사하겠습니다.

코드를 추가 레이어 :

UIView *student = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; 
    student.backgroundColor = [UIColor grayColor]; 

    CALayer *studentLayer = [[CALayer alloc] init]; 
    studentLayer.borderColor = [UIColor grayColor].CGColor; 
    studentLayer.borderWidth = 5; 

    student.layer.borderColor = studentLayer.borderColor; 
    student.layer.borderWidth = studentLayer.borderWidth; 

코드 추가 하위 뷰를 위해 : 도움이된다면 여기

내 코드입니다

UILabel *ilp = [[UILabel alloc] initWithFrame:(CGRectMake(-20, -10, 40, 20))]; 
    ilp.text = @"ILP"; 
    ilp.backgroundColor = [UIColor yellowColor]; 
    ilp.textColor = [UIColor blackColor]; 
    ilp.textAlignment = NSTextAlignmentCenter; 

    [student addSubview:ilp]; 

답변

3

그게 가능하지 지금까지 가장 좋은 해결책을 내가 생각할 수있는 것은 두 개의 하위보기를 재정렬하는 것보다 다른보기 내부에 하위보기와 상위보기를 모두 추가하여 하위보기가 다른보기보다 위쪽에 있도록하는 것입니다.

희망 하시겠습니까?

+0

안녕하세요, 대단히 감사합니다. –