2013-04-17 56 views
0

我創建了一個圖像地圖,其中包含scrollview內的imageview,在我的圖像視圖中,如果在特定部分上觸摸,然後我想在該特定部分上繪製文本。在圖像地圖上書寫或繪製文字

是否有任何圖書館?

回答

0

可以通過先獲取觸摸點,像這樣做自己:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *aTouch = [touches anyObject]; 
    CGPoint point = [aTouch locationInView:self]; 
    CGFloat xPos = point.x; 
    CGFloat yPos = point.y; 
} 

然後利用這些信息並做出帶有x和y作爲參數的方法。並以編程方式創建一個UITextField。

UITextField * textFieldRounded = [[UITextField alloc] initWithFrame:CGRectMake(inParameterX, inParameterY, 300, 50)]; 
textFieldRounded.textColor = [UIColor blackColor]; 
textFieldRounded.font = [UIFont systemFontOfSize:17.0]; 
textFieldRounded.backgroundColor = [UIColor clearColor]; 
textFieldRounded.autocorrectionType = UITextAutocorrectionTypeNo; 
textFieldRounded.keyboardType = UIKeyboardTypeDefault; 
textFieldRounded.returnKeyType = UIReturnKeyDone; 
textFieldRounded.clearButtonMode = UITextFieldViewModeWhileEditing; 

然後將其添加到您的視圖:

[self.view addSubview:textFieldRounded]; 

根據您要與文本字段做什麼,你可以做一個對象來代替。也許保存到一個數組。那麼你明白了。