2010-12-08 12 views

답변

3

이미지 상단에 텍스트가 포함 된 추가보기를 합성하면됩니다. [UIColor clearColor]과 함께 UILabel을 배경색으로 사용하고 불투명도를 false로 설정하면 이미지 상단에 텍스트가 표시되고 이미지가 흐려지지 않습니다. 이 같은

How to obtain a CGImageRef from the content of an UIView?

뭔가 :

UIView* baseView = [[UIView alloc] initWithFrame:frameSize]; 

    UIImage* imageToCaption = [UIImage imageNamed:@"myImage.jpg"]; 
    UIImageView* imageToCaptionView = [[UIImageView alloc] initWithImage:imageToCaption]; 
    imageToCaptionView.frame = frameSize; 
    [baseView addSubview:imageToCaptionView]; 
    [imageToCaptionView release]; 


    // do stuff with fonts to calculate the size of the label, center it in your image etc. etc. 
    CGRect labelFrame = ... 

    UILabel* myLabel = [[UILabel alloc] initWithFrame:labelFrame]; 
    myLabel.backgroundColor = [UIColor clearColor]; 
    myLabel.opaque = NO; 

    // set the color, font, text etc. 

    [baseView addSubView:myLabel]; 
    [myLabel release]; 
당신이 그 위에 텍스트를 포함하는 투명 볼 수있는보기 이미지에서 이미지를 얻고 싶다면

,이 답변을 참조

컴파일되지 않았거나 완료되었지만 아이디어를 얻었습니다. 결과를 이미지로 사용하고 싶다면 [baseView.layer renderInContext:context];

+0

@admm : pls가 코드 샘플을 제공 할 수 있습니까? – user198725878

관련 문제