2010-12-08 11 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

関連する問題