2012-06-28 2 views
0

스크롤보기가 있습니다 (IBOutlet). 해당 scrollview 난 imageview 추가했습니다. 크기에 따라 이미지에 레이블을 추가하려고합니다. 예를 들어 TR (오른쪽 상단), TC (상단 중앙), C (중앙) ... 이미지가 아이폰의 해상도 (예 : 300x160)보다 작다고 가정하면 이미지에 레이블을 붙일 수있는 9 가지 옵션이 있습니다. 이제 이미지보기에서 레이블을로드하고 있지만 제대로 작동하지 않습니다. 레이블 맞춤이 올바르지 않습니다. 내 맞춤 버튼 코드는 다음과 같습니다.이미지보기에서 라벨을 정렬하는 방법은 무엇입니까?

-(IBAction)btn_AlignPressed:(UIButton*)sender{ 
    lbl.tag = sender.tag; 
    [imgView addSubview:lbl]; 
    if (sender.tag == 1) { 
     lbl.frame = CGRectMake(0, 0, imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 2) { 
     lbl.frame = CGRectMake(160-(imgView.frame.size.width/2), 0, imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 3) { 
     lbl.frame = CGRectMake(320-imgView.frame.size.width, 0, imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 4) { 
     lbl.frame = CGRectMake(0, 210-(imgView.frame.size.height/2), imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 5) { 
     lbl.frame = CGRectMake(160-(imgView.frame.size.width/2), 210-(imgView.frame.size.height/2), imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 6) { 
     lbl.frame = CGRectMake(320-imgView.frame.size.width, 210-(imgView.frame.size.height/2), imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 7) { 
     lbl.frame = CGRectMake(0, 420-imgView.frame.size.height, imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 8) { 
     lbl.frame = CGRectMake(160-(imgView.frame.size.width/2), 420-imgView.frame.size.height, imgView.frame.size.width, imgView.frame.size.height); 
    } else if(sender.tag == 9) { 
     lbl.frame = CGRectMake(320-imgView.frame.size.width, 420-imgView.frame.size.height, imgView.frame.size.width, imgView.frame.size.height); 
    } 
} 

도와주세요. 사전에

감사합니다.

답변

0

x 및 y 값만 설정하고 레이블의 너비와 높이에 대해서도 작업해야합니다.

관련 문제