2017-02-20 65 views
1

enter image description here如何在iOS中添加多個文本到視頻中,如圖所示?

我有多個文本添加到視頻像輪廓page.there應該是正確對齊的text.i我對齊面臨的問題,並新增多個文字。幫我解決這個問題!

CALayer *parentLayer = [CALayer layer]; 
    CALayer *videoLayer = [CALayer layer]; 
    parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); 
    videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); 
    videoLayer.masksToBounds=YES; 
    [parentLayer addSublayer:videoLayer]; 
    [parentLayer addSublayer:aLayer]; 

    CATextLayer *titleLayer = [CATextLayer layer]; 
    titleLayer.string = @" Candidate Name "; 
    titleLayer.font = CFBridgingRetain(@"Helvetica"); 
    titleLayer.fontSize =15.0f; 
    [titleLayer setFrame:CGRectMake(20.0f, 20.0f, videoSize.width, 30)]; // CGRectMake(0.0f, 0.0f,videoSize.width, videoSize.height); 
    titleLayer.opacity=0.0; 
    //?? titleLayer.shadowOpacity = 0.5; 
    titleLayer.alignmentMode = kCAAlignmentCenter; 
    // titleLayer.bounds = CGRectMake(0.5f, 0.5f, videoSize.width, 30); //You may need to adjust this for proper display 
    [aLayer addSublayer:titleLayer]; //ONLY IF WE ADDED TEXT 


    CATextLayer *titleLayer1 = [CATextLayer layer]; 
    titleLayer1.string = @" Raman Srivastava"; 
    titleLayer1.font = CFBridgingRetain(@"Helvetica"); 
    titleLayer1.fontSize =15.0f; 
    [titleLayer1 setFrame:CGRectMake(25.0f,20.0f,videoSize.width, 30)]; 
    titleLayer1.opacity=0.0; 
    //?? titleLayer.shadowOpacity = 0.5; 
    titleLayer1.alignmentMode = kCAAlignmentLeft; 
    // titleLayer.bounds = CGRectMake(10, 10, videoSize.width, videoSize.height/6); //You may need to adjust this for proper display 
    [aLayer addSublayer:titleLayer1]; //ONLY IF WE ADDED TEXT 
+0

UITableView與自定義UITableViewCell? UIStackView? – Larme

+0

@Larme看到我的更新問題 –

回答

0

然後,您也可以在圖層上設置調整大小遮罩,以便對視圖的更改會反映在圖層中。

+0

這是如何回答這個問題?如果您沒有足夠的信譽評論,請不要發表評論作爲答案。我已經低估了,編輯它,並將其作爲一個實際的答案,我會upvote你。 – 2017-02-20 15:01:45

相關問題