1

I have a UIImageView called imgView which was added by

[self.view addSubview:imgView]; 

when I draw line in view's drawrect method, the line shows below imgView, but i want it shows on imgView. ps: i also tried

 [self.view insertSubview:imgView atIndex:0]; 

which hides the imgView i.e I could see it on the view

[self.view addSubview:imgView]; 

and

[self.view sendSubviewToBack:imgView]; 

that also didn't work.

What could be wrong?

2 Answers 2

1

Draw your image in the drawRect method, then draw the line.

[img drawAtPoint:your_point]; // Code to draw the line 
Sign up to request clarification or add additional context in comments.

1 Comment

i add many images into view and i need drag or move it and there some other operations on these images, in all words , i can't draw image to view in drawRect method. please help me! thanks!
0

I know it's late, but still, could be usefull to someone.

The reason why line is under image - is because everything you do in drawRect, will be below every subview. So if you would want a line on top of image, you would need to add to imageview an UIView subview class, in which You have corresponding drawrect with line drawing.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.