0

我创建了一个图像映射,其中包含 scrollview 内的 imageview ,如果在我的 imageview 中触摸特定部分,那么我想在该特定部分上绘制文本。

有没有图书馆?

4

1 回答 1

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];

根据您要对文本字段执行的操作,您可以创建一个对象。并可能将其保存到数组中。好吧,你明白了。

于 2013-04-17T07:55:58.813 回答