2015-02-10 183 views
0

文字我儘量簡短:我正在尋找一種方法來簡單地繪製文本(類似的東西:在屏幕上drawTextOnScreen:(NSString)stringToDraw at:(CGPoint)point就像畫一條線,例如:在屏幕上繪製

UIBezierPath *path = [UIBezierPath bezierPath]; 
    [path moveToPoint:CGPointMake(center.x, center.y+innerRadius)]; //lower 
    [path addLineToPoint:CGPointMake(center.x, center.y+outerRadius)]; 

我真的不能找到一個簡單的任務像一個簡單的解決方案。

我瞄準iOS8上

+0

使用核心動畫路徑圖層併爲其設置動畫效果。 – Abizern 2015-02-10 18:49:13

+0

你能解釋一下嗎?我什至不知道谷歌 – moobi 2015-02-10 19:31:35

回答

0

因此,我現在正在使用此解決方案。感謝InkGolem提供的小提示。此代碼將字符串「textOnScreen」寫入x = 75和y = 35的位置並顯示黃色。

UILabel *uiLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 20, 15)]; 
uiLabel.text = @"textOnScreen"; 
uiLabel.frame=CGRectMake(75, 35, 160, 20); 
uiLabel.font=[UIFont boldSystemFontOfSize:25.0]; 
uiLabel.textColor=[UIColor yellowColor]; 
uiLabel.backgroundColor=[UIColor clearColor]; 
[self.view addSubview:uiLabel]; 
2

那麼如果你想要一個簡單的方法來繪製一個字符串,可以使用UILabel

如果你必須使用核心圖形,你可以使用[NSString drawInRect: withAttributes:]

+0

我正在使用'AVCaputreSession'爲相機。我喜歡將此文本顯示爲實際攝像機視圖的覆蓋圖。使用'[NSString drawInRect:withAttributes:]'這可能嗎? – moobi 2015-02-10 19:04:59

+0

只需添加一個UILabel作爲CameraView的子視圖。 – InkGolem 2015-02-10 20:50:57