I need to add some numbers / text, programmatically so it shows on top of an image I have specified for several UIImageViews. Also my users are able to drag the image view around the screen. I need the text to move at the same time. To move the image views I use this code..
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
for (id football in multipleFootballs) {
UITouch *touch = [touches anyObject];
if ([touch view] == football) {
CGPoint pt = [[touches anyObject] locationInView:football];
CGRect frame = [football frame];
frame.origin.x += pt.x - startLocation.x;
frame.origin.y += pt.y - startLocation.y;
[football setFrame:frame];
}
}
}
Just about any
UIVieworUIViewdescendent can be added to any otherUIViewas a subview. So you could create aUILabelwith your text and add it as a subview to yourUIImageViewsusing an appropriateCGRectfor theUILabel‘s frame to position it where you want it in yourUIImageView.